Revision 7812
Added by ben leinfelder almost 11 years ago
SystemMetadataEventListener.java | ||
---|---|---|
38 | 38 |
import org.dataone.service.types.v1.Identifier; |
39 | 39 |
import org.dataone.service.types.v1.SystemMetadata; |
40 | 40 |
|
41 |
import com.hazelcast.core.EntryEvent; |
|
42 |
import com.hazelcast.core.EntryListener; |
|
43 | 41 |
import com.hazelcast.core.IMap; |
42 |
import com.hazelcast.core.ISet; |
|
43 |
import com.hazelcast.core.ItemEvent; |
|
44 |
import com.hazelcast.core.ItemListener; |
|
44 | 45 |
|
45 |
public class SystemMetadataEventListener implements EntryListener<Identifier, SystemMetadata> {
|
|
46 |
public class SystemMetadataEventListener implements ItemListener<SystemMetadata> {
|
|
46 | 47 |
|
47 | 48 |
private static Log log = LogFactory.getLog(SystemMetadataEventListener.class); |
48 | 49 |
|
... | ... | |
94 | 95 |
|
95 | 96 |
// get shared structures and add listener |
96 | 97 |
IMap<Identifier, String> objectPathMap = DistributedMapsFactory.getObjectPathMap(); |
97 |
IMap<Identifier, SystemMetadata> systemMetadataMap = DistributedMapsFactory.getSystemMetadataMap();
|
|
98 |
systemMetadataMap.addEntryListener(this, true);
|
|
99 |
log.info("System Metadata size: " + systemMetadataMap.size());
|
|
98 |
ISet<SystemMetadata> indexQueue = DistributedMapsFactory.getIndexQueue();
|
|
99 |
indexQueue.addItemListener(this, true);
|
|
100 |
log.info("System Metadata size: " + indexQueue.size());
|
|
100 | 101 |
log.info("Object path size:" + objectPathMap.size()); |
101 | 102 |
} |
102 | 103 |
|
... | ... | |
107 | 108 |
*/ |
108 | 109 |
public void stop() throws FileNotFoundException, ServiceFailure { |
109 | 110 |
log.info("stopping index entry listener..."); |
110 |
DistributedMapsFactory.getSystemMetadataMap().removeEntryListener(this);
|
|
111 |
DistributedMapsFactory.getIndexQueue().removeItemListener(this);
|
|
111 | 112 |
} |
112 | 113 |
|
113 | 114 |
/** |
... | ... | |
135 | 136 |
return obsoletes; |
136 | 137 |
} |
137 | 138 |
|
138 |
|
|
139 |
|
|
140 |
public void entryAdded(EntryEvent<Identifier, SystemMetadata> entryEvent) { |
|
141 |
//System.out.println("===================================calling entryAdded method "); |
|
142 |
log.info("===================================calling entryAdded method "); |
|
143 |
// use the same implementation for insert/update for now |
|
144 |
this.entryUpdated(entryEvent); |
|
145 | 139 |
|
146 |
} |
|
147 |
|
|
148 |
public void entryEvicted(EntryEvent<Identifier, SystemMetadata> entryEvent) { |
|
149 |
// remove from the index for now, this may be a temporary eviction |
|
150 |
this.entryRemoved(entryEvent); |
|
151 |
|
|
152 |
} |
|
153 |
|
|
154 |
public void entryRemoved(EntryEvent<Identifier, SystemMetadata> entryEvent) { |
|
140 |
public void itemRemoved(ItemEvent<SystemMetadata> entryEvent) { |
|
155 | 141 |
// remove from the index |
156 |
Identifier pid = entryEvent.getKey();
|
|
142 |
Identifier pid = entryEvent.getItem().getIdentifier();
|
|
157 | 143 |
try { |
158 | 144 |
solrIndex.remove(pid.getValue()); |
159 | 145 |
} catch (Exception e) { |
... | ... | |
163 | 149 |
|
164 | 150 |
} |
165 | 151 |
|
166 |
public void entryUpdated(EntryEvent<Identifier, SystemMetadata> entryEvent) {
|
|
152 |
public void itemAdded(ItemEvent<SystemMetadata> entryEvent) {
|
|
167 | 153 |
//System.out.println("===================================calling entryUpdated method "); |
168 | 154 |
log.info("===================================calling entryUpdated method "); |
169 | 155 |
// add to the index |
170 |
Identifier pid = entryEvent.getKey();
|
|
156 |
Identifier pid = entryEvent.getItem().getIdentifier();
|
|
171 | 157 |
//System.out.println("===================================update the document "+pid.getValue()); |
172 | 158 |
log.info("===================================update the document "+pid.getValue()); |
173 |
SystemMetadata systemMetadata = entryEvent.getValue();
|
|
159 |
SystemMetadata systemMetadata = entryEvent.getItem();
|
|
174 | 160 |
Identifier obsoletes = systemMetadata.getObsoletes(); |
175 | 161 |
List<String> obsoletesChain = null; |
176 | 162 |
if (obsoletes != null) { |
Also available in: Unified diff
use an independent ISet<SystemMetadata> structure to communicate objects that should be indexed by metacat-index. https://projects.ecoinformatics.org/ecoinfo/issues/5943