Project

General

Profile

« Previous | Next » 

Revision 8283

merge from 2.2 branch: remove the index queue item when it is being processed. https://projects.ecoinformatics.org/ecoinfo/issues/6117

View differences:

metacat-index/src/main/java/edu/ucsb/nceas/metacat/index/SystemMetadataEventListener.java
45 45
	private static Log log = LogFactory.getLog(SystemMetadataEventListener.class);
46 46
	
47 47
	private SolrIndex solrIndex = null;
48
	
49
	private ISet<SystemMetadata> source = null;
48 50
	        
49 51
    /**
50 52
     * Default constructor - caller needs to initialize manually
......
94 96
        IMap<Identifier, String> objectPathMap = DistributedMapsFactory.getObjectPathMap();
95 97
        ISet<SystemMetadata> indexQueue = DistributedMapsFactory.getIndexQueue();
96 98
        indexQueue.addItemListener(this, true);
99
        this.source = indexQueue;
97 100
        log.info("System Metadata size: " + indexQueue.size());
98 101
        log.info("Object path size:" + objectPathMap.size());
99 102
    }
......
135 138
    
136 139

  
137 140
	public void itemRemoved(ItemEvent<SystemMetadata> entryEvent) {
138
		// remove from the index
139
		Identifier pid = entryEvent.getItem().getIdentifier();
140
		if(pid != null) {
141
		    try {
142
	            solrIndex.remove(pid.getValue());
143
	        } catch (Exception e) {
144
	            String error = "SystemMetadataEventListener.itemRemoved - couldn't remove the index for the pid "+pid.getValue()+" since "+e.getMessage();
145
	            SystemMetadata systemMetadata = entryEvent.getItem();
146
	            writeEventLog(systemMetadata, pid, error);
147
	            log.error(error, e);
148
	        }
149
		}
150
		
151
		
141
		// do nothing - indexing acts on added objects, even if they need to be deleted
152 142
	}
153 143

  
154 144
	public void itemAdded(ItemEvent<SystemMetadata> entryEvent) {
......
163 153
		    writeEventLog(systemMetadata, pid, "SystemMetadataEventListener.itemAdded -could not get the SystemMetadata");
164 154
		    return;
165 155
		}
156
		
157
		// make sure we remove this object so that it can be re-added in the future
158
		if (source != null) {
159
			source.remove(systemMetadata);
160
		}
161
				
166 162
		Identifier obsoletes = systemMetadata.getObsoletes();
167 163
		List<String> obsoletesChain = null;
168 164
		if (obsoletes != null) {

Also available in: Unified diff