Project

General

Profile

1
/**
2
 *  '$RCSfile$'
3
 *    Purpose: Implements a service for managing a Hazelcast cluster member
4
 *  Copyright: 2011 Regents of the University of California and the
5
 *             National Center for Ecological Analysis and Synthesis
6
 *    Authors: Christopher Jones
7
 * 
8
 *   '$Author: leinfelder $'
9
 *     '$Date: 2012-08-01 22:40:00 -0700 (Wed, 01 Aug 2012) $'
10
 * '$Revision: 7339 $'
11
 *
12
 * This program is free software; you can redistribute it and/or modify
13
 * it under the terms of the GNU General Public License as published by
14
 * the Free Software Foundation; either version 2 of the License, or
15
 * (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU General Public License
23
 * along with this program; if not, write to the Free Software
24
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
 */
26

    
27
package edu.ucsb.nceas.metacat.dataone.hazelcast;
28

    
29
import java.io.FileNotFoundException;
30
import java.sql.SQLException;
31
import java.util.HashSet;
32
import java.util.Iterator;
33
import java.util.List;
34
import java.util.Set;
35
import java.util.concurrent.ExecutorService;
36
import java.util.concurrent.Executors;
37
import java.util.concurrent.locks.Lock;
38

    
39
import org.apache.log4j.Logger;
40
import org.dataone.service.exceptions.InvalidSystemMetadata;
41
import org.dataone.service.types.v1.Identifier;
42
import org.dataone.service.types.v1.Node;
43
import org.dataone.service.types.v1.NodeReference;
44
import org.dataone.service.types.v1.SystemMetadata;
45

    
46
import com.hazelcast.config.Config;
47
import com.hazelcast.config.FileSystemXmlConfig;
48
import com.hazelcast.core.EntryEvent;
49
import com.hazelcast.core.EntryListener;
50
import com.hazelcast.core.Hazelcast;
51
import com.hazelcast.core.HazelcastInstance;
52
import com.hazelcast.core.IMap;
53
import com.hazelcast.core.ISet;
54
import com.hazelcast.core.LifecycleEvent;
55
import com.hazelcast.core.LifecycleListener;
56
import com.hazelcast.core.Member;
57
import com.hazelcast.core.MembershipEvent;
58
import com.hazelcast.core.MembershipListener;
59
import com.hazelcast.partition.Partition;
60
import com.hazelcast.partition.PartitionService;
61

    
62
import edu.ucsb.nceas.metacat.IdentifierManager;
63
import edu.ucsb.nceas.metacat.McdbDocNotFoundException;
64
import edu.ucsb.nceas.metacat.properties.PropertyService;
65
import edu.ucsb.nceas.metacat.shared.BaseService;
66
import edu.ucsb.nceas.metacat.shared.ServiceException;
67
import edu.ucsb.nceas.metacat.util.DocumentUtil;
68
import edu.ucsb.nceas.utilities.FileUtil;
69
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
70
/**
71
 * The Hazelcast service enables Metacat as a Hazelcast cluster member
72
 */
73
public class HazelcastService extends BaseService
74
  implements EntryListener<Identifier, SystemMetadata>, MembershipListener, LifecycleListener {
75
  
76
  private static final String SINCE_PROPERTY = "dateSysMetadataModified";
77

    
78
/* The instance of the logging class */
79
  private static Logger logMetacat = Logger.getLogger(HazelcastService.class);
80
  
81
  /* The singleton instance of the hazelcast service */
82
  private static HazelcastService hzService = null;
83
  
84
  /* The Hazelcast configuration */
85
  private Config hzConfig;
86
  
87
  /* The instance of the Hazelcast client */
88
//  private HazelcastClient hzClient;
89

    
90
  /* The name of the DataONE Hazelcast cluster group */
91
  private String groupName;
92

    
93
  /* The name of the DataONE Hazelcast cluster password */
94
  private String groupPassword;
95
  
96
  /* The name of the DataONE Hazelcast cluster IP addresses */
97
  private String addressList;
98
  
99
  /* The name of the node map */
100
  private String nodeMap;
101

    
102
  /* The name of the system metadata map */
103
  private String systemMetadataMap;
104
  
105
  /* The Hazelcast distributed task id generator namespace */
106
  private String taskIds;
107
  
108
  /* The Hazelcast distributed node map */
109
  private IMap<NodeReference, Node> nodes;
110

    
111
  /* The Hazelcast distributed system metadata map */
112
  private IMap<Identifier, SystemMetadata> systemMetadata;
113
  
114
  /* The name of the identifiers set */
115
  private String identifiersSet;
116
  
117
  /* The Hazelcast distributed identifiers set */
118
  private ISet<Identifier> identifiers;
119

    
120
  private HazelcastInstance hzInstance;
121
      
122
  /*
123
   * Constructor: Creates an instance of the hazelcast service. Since
124
   * this uses a singleton pattern, use getInstance() to gain the instance.
125
   */
126
  private HazelcastService() {
127
    
128
    super();
129
    _serviceName="HazelcastService";
130
    
131
    try {
132
      init();
133
      
134
    } catch (ServiceException se) {
135
      logMetacat.error("There was a problem creating the HazelcastService. " +
136
                       "The error message was: " + se.getMessage());
137
      
138
    }
139
    
140
  }
141
  
142
  /**
143
   *  Get the instance of the HazelcastService that has been instantiated,
144
   *  or instantiate one if it has not been already.
145
   *
146
   * @return hazelcastService - The instance of the hazelcast service
147
   */
148
  public static HazelcastService getInstance(){
149
    
150
    if ( hzService == null ) {
151
      
152
      hzService = new HazelcastService();
153
      
154
    }
155
    return hzService;
156
  }
157
  
158
  /**
159
   * Initializes the Hazelcast service
160
   */
161
  public void init() throws ServiceException {
162
    
163
    logMetacat.debug("HazelcastService.init() called.");
164
    
165
	String configFileName = null;
166
	Config config = null;
167
	try {
168
		configFileName = PropertyService.getProperty("dataone.hazelcast.configFilePath");
169
		config = new FileSystemXmlConfig(configFileName);
170
	} catch (Exception e) {
171
		configFileName = PropertyService.CONFIG_FILE_DIR + FileUtil.getFS() + "hazelcast.xml";
172
		logMetacat.warn("Custom Hazelcast configuration not defined, using default: " + configFileName);
173
		// make sure we have the config
174
		try {
175
			config = new FileSystemXmlConfig(configFileName);
176
		} catch (FileNotFoundException e1) {
177
			String msg = e.getMessage();
178
			logMetacat.error(msg);
179
			throw new ServiceException(msg);
180
		}
181
	}
182

    
183
	Hazelcast.init(config);
184
	this.hzInstance = Hazelcast.getDefaultInstance();
185
  
186
  	logMetacat.debug("Initialized hzInstance");
187

    
188
    // Get configuration properties on instantiation
189
    try {
190
      groupName = 
191
        PropertyService.getProperty("dataone.hazelcast.processCluster.groupName");
192
      groupPassword = 
193
        PropertyService.getProperty("dataone.hazelcast.processCluster.password");
194
      addressList = 
195
        PropertyService.getProperty("dataone.hazelcast.processCluster.instances");
196
      systemMetadataMap = 
197
        PropertyService.getProperty("dataone.hazelcast.storageCluster.systemMetadataMap");
198
      identifiersSet = PropertyService.getProperty("dataone.hazelcast.storageCluster.identifiersSet");
199
//    nodeMap = 
200
//    PropertyService.getProperty("dataone.hazelcast.processCluster.nodesMap");
201
      // Become a DataONE-process cluster client
202
//      String[] addresses = addressList.split(",");
203
//      hzClient = 
204
//        HazelcastClient.newHazelcastClient(this.groupName, this.groupPassword, addresses);
205
//      nodes = hzClient.getMap(nodeMap);
206
      
207
      // Get a reference to the shared system metadata map as a cluster member
208
      // NOTE: this loads the map from the backing store and can take a long time for large collections
209
      systemMetadata = Hazelcast.getMap(systemMetadataMap);
210
      
211
      logMetacat.debug("Initialized systemMetadata");
212

    
213
      // Get a reference to the shared identifiers set as a cluster member
214
      // NOTE: this takes a long time to complete
215
      logMetacat.warn("Retrieving hzIdentifiers from Hazelcast");
216
      identifiers = Hazelcast.getSet(identifiersSet);
217
      logMetacat.warn("Retrieved hzIdentifiers from Hazelcast");
218
      
219
      // Listen for changes to the system metadata map
220
      systemMetadata.addEntryListener(this, true);
221
      
222
      // Listen for members added/removed
223
      hzInstance.getCluster().addMembershipListener(this);
224
      
225
      // Listen for lifecycle state changes
226
      hzInstance.getLifecycleService().addLifecycleListener(this);
227
      
228
    } catch (PropertyNotFoundException e) {
229

    
230
      String msg = "Couldn't find Hazelcast properties for the DataONE clusters. " +
231
        "The error message was: " + e.getMessage();
232
      logMetacat.error(msg);
233
      
234
    }
235
    
236
    // make sure we have all metadata locally
237
    try {
238
    	// synch on restart
239
        resynchInThread();
240
	} catch (Exception e) {
241
		String msg = "Problem resynchronizing system metadata. " + e.getMessage();
242
		logMetacat.error(msg, e);
243
	}
244
        
245
  }
246
  
247
  /**
248
   * Get the system metadata map
249
   * 
250
   * @return systemMetadata - the hazelcast map of system metadata
251
   * @param identifier - the identifier of the object as a string
252
   */
253
  public IMap<Identifier,SystemMetadata> getSystemMetadataMap() {
254
	  return systemMetadata;
255
  }
256
  
257
  /**
258
   * Get the identifiers set
259
   * @return identifiers - the set of unique DataONE identifiers in the cluster
260
   */
261
  public ISet<Identifier> getIdentifiers() {
262
      return identifiers;
263
      
264
  }
265

    
266
  /**
267
   * When Metacat changes the underlying store, we need to refresh the
268
   * in-memory representation of it.
269
   * @param guid
270
   */
271
  public void refreshSystemMetadataEntry(String guid) {
272
	Identifier identifier = new Identifier();
273
	identifier.setValue(guid);
274
	// force hazelcast to update system metadata in memory from the store
275
	HazelcastService.getInstance().getSystemMetadataMap().evict(identifier);
276
	
277
  }
278

    
279
  public Lock getLock(String identifier) {
280
    
281
    Lock lock = null;
282
    
283
    try {
284
        lock = getInstance().getHazelcastInstance().getLock(identifier);
285
        
286
    } catch (RuntimeException e) {
287
        logMetacat.info("Couldn't get a lock for identifier " + 
288
            identifier + " !!");
289
    }
290
    return lock;
291
      
292
  }
293
  
294
  /**
295
   * Get the DataONE hazelcast node map
296
   * @return nodes - the hazelcast map of nodes
297
   */
298
//  public IMap<NodeReference, Node> getNodesMap() {
299
//	  return nodes;
300
//  }
301
  
302
  /**
303
   * Indicate whether or not this service is refreshable.
304
   *
305
   * @return refreshable - the boolean refreshable status
306
   */
307
  public boolean refreshable() {
308
    // TODO: Determine the consequences of restarting the Hazelcast instance
309
    // Set this to true if it's okay to drop from the cluster, lose the maps,
310
    // and start back up again
311
    return false;
312
    
313
  }
314
  
315
  /**
316
   * Stop the HazelcastService. When stopped, the service will no longer
317
   * respond to requests.
318
   */
319
  public void stop() throws ServiceException {
320
    
321
    Hazelcast.getLifecycleService().shutdown();
322
    
323
  }
324

    
325
  public HazelcastInstance getHazelcastInstance() {
326
      return this.hzInstance;
327
      
328
  }
329
  
330
  /**
331
   * Refresh the Hazelcast service by restarting it
332
   */
333
  @Override
334
  protected void doRefresh() throws ServiceException {
335

    
336
    // TODO: verify that the correct config file is still used
337
    Hazelcast.getLifecycleService().restart();
338
    
339
  }
340
  
341
  /**
342
	 * Implement the EntryListener interface for Hazelcast, reponding to entry
343
	 * added events in the hzSystemMetadata map. Evaluate the entry and create
344
	 * CNReplicationTasks as appropriate (for DATA, METADATA, RESOURCE)
345
	 * 
346
	 * @param event - The EntryEvent that occurred
347
	 */
348
	@Override
349
	public void entryAdded(EntryEvent<Identifier, SystemMetadata> event) {
350
	  
351
	  logMetacat.info("SystemMetadata entry added event on identifier " + 
352
	      event.getKey().getValue());
353
		// handle as update - that method will create if necessary
354
		entryUpdated(event);
355

    
356
	}
357

    
358
	/**
359
	 * Implement the EntryListener interface for Hazelcast, reponding to entry
360
	 * evicted events in the hzSystemMetadata map.  Evaluate the entry and create
361
	 * CNReplicationTasks as appropriate (for DATA, METADATA, RESOURCE)
362
	 * 
363
	 * @param event - The EntryEvent that occurred
364
	 */
365
	@Override
366
	public void entryEvicted(EntryEvent<Identifier, SystemMetadata> event) {
367

    
368
      logMetacat.info("SystemMetadata entry evicted event on identifier " + 
369
          event.getKey().getValue());
370
      
371
	    // ensure identifiers are listed in the hzIdentifiers set
372
      if ( !identifiers.contains(event.getKey()) ) {
373
          identifiers.add(event.getKey());
374
      }
375
	  
376
	}
377
	
378
	/**
379
	 * Implement the EntryListener interface for Hazelcast, reponding to entry
380
	 * removed events in the hzSystemMetadata map.  Evaluate the entry and create
381
	 * CNReplicationTasks as appropriate (for DATA, METADATA, RESOURCE)
382
	 * 
383
	 * @param event - The EntryEvent that occurred
384
	 */
385
	@Override
386
	public void entryRemoved(EntryEvent<Identifier, SystemMetadata> event) {
387
		
388
    logMetacat.info("SystemMetadata entry removed event on identifier " + 
389
        event.getKey().getValue());
390

    
391
	  // we typically don't remove objects in Metacat, but can remove System Metadata
392
		IdentifierManager.getInstance().deleteSystemMetadata(event.getValue().getIdentifier().getValue());
393

    
394
    // keep the hzIdentifiers set in sync with the systemmetadata table
395
    if ( identifiers.contains(event.getKey()) ) {
396
        identifiers.remove(event.getKey());
397
        
398
    }
399

    
400
	}
401
	
402
	/**
403
	 * Implement the EntryListener interface for Hazelcast, reponding to entry
404
	 * updated events in the hzSystemMetadata map.  Evaluate the entry and create
405
	 * CNReplicationTasks as appropriate (for DATA, METADATA, RESOURCE)
406
	 * 
407
	 * @param event - The EntryEvent that occurred
408
	 */
409
	@Override
410
	public void entryUpdated(EntryEvent<Identifier, SystemMetadata> event) {
411

    
412
		logMetacat.debug("Entry added/updated to System Metadata map: " + event.getKey().getValue());
413
		PartitionService partitionService = Hazelcast.getPartitionService();
414
		Partition partition = partitionService.getPartition(event.getKey());
415
		Member ownerMember = partition.getOwner();
416
		SystemMetadata sysmeta = event.getValue();
417
		if (!ownerMember.localMember()) {
418
			if (sysmeta == null) {
419
				logMetacat.warn("No SystemMetadata provided in the event, getting from shared map: " + event.getKey().getValue());
420
				sysmeta = getSystemMetadataMap().get(event.getKey());
421
				if (sysmeta == null) {
422
					// this is a problem
423
					logMetacat.error("Could not find SystemMetadata in shared map for: " + event.getKey().getValue());
424
					// TODO: should probably return at this point since the save will fail
425
				}
426
			}
427
			// need to pull the entry into the local store
428
			saveLocally(event.getValue());
429
		}
430

    
431
		// ensure identifiers are listed in the hzIdentifiers set
432
		if (!identifiers.contains(event.getKey())) {
433
			identifiers.add(event.getKey());
434
		}
435

    
436
	}
437
	
438
	/**
439
	 * Save SystemMetadata to local store if needed
440
	 * @param sm
441
	 */
442
	private void saveLocally(SystemMetadata sm) {
443
		logMetacat.debug("Saving entry locally: " + sm.getIdentifier().getValue());
444
		try {
445

    
446
			IdentifierManager.getInstance().insertOrUpdateSystemMetadata(sm);
447

    
448
		} catch (McdbDocNotFoundException e) {
449
			logMetacat.error("Could not save System Metadata to local store.", e);
450
			
451
		} catch (SQLException e) {
452
	      logMetacat.error("Could not save System Metadata to local store.", e);
453
	      
454
	    } catch (InvalidSystemMetadata e) {
455
	        logMetacat.error("Could not save System Metadata to local store.", e);
456
	        
457
	    }
458
	}
459
	
460
	/**
461
	 * Checks the local backing store for missing SystemMetadata,
462
	 * retrieves those entries from the shared map if they exist,
463
	 * and saves them locally.
464
	 */
465
	private void synchronizeLocalStore() {
466
		List<String> localIds = IdentifierManager.getInstance().getLocalIdsWithNoSystemMetadata(true, -1);
467
		if (localIds != null) {
468
			logMetacat.debug("Member missing SystemMetadata entries, count = " + localIds.size());
469
			for (String localId: localIds) {
470
				logMetacat.debug("Processing system metadata for localId: " + localId);
471
				try {
472
					String docid = DocumentUtil.getSmartDocId(localId);
473
					int rev = DocumentUtil.getRevisionFromAccessionNumber(localId);
474
					String guid = IdentifierManager.getInstance().getGUID(docid, rev);
475
					logMetacat.debug("Found mapped guid: " + guid);
476
					Identifier pid = new Identifier();
477
					pid.setValue(guid);
478
					SystemMetadata sm = systemMetadata.get(pid);
479
					logMetacat.debug("Found shared system metadata for guid: " + guid);
480
					saveLocally(sm);
481
					logMetacat.debug("Saved shared system metadata locally for guid: " + guid);
482
				} catch (Exception e) {
483
					logMetacat.error("Could not save shared SystemMetadata entry locally, localId: " + localId, e);
484
				}
485
			}
486
		}
487
	}
488
	
489
	
490
	/**
491
	 * Make sure we have a copy of every entry in the shared map.
492
	 * We use lazy loading and therefore the CNs may not all be in sync when one
493
	 * comes back online after an extended period of being offline
494
	 * This method loops through the entries that a FULLY UP-TO-DATE CN has
495
	 * and makes sure each one is present on the shared map.
496
	 * It is meant to overcome a HZ weakness wherein ownership of a key results in 
497
	 * null values where the owner does not have a complete backing store.
498
	 * This will be an expensive routine and should be run in a background process so that
499
	 * the server can continue to service other requests during the synch
500
	 * @throws Exception
501
	 */
502
	private void resynchToRemote() {
503
		
504
		// add any identifiers not already present in the shared map
505
		Set<Identifier> idKeys = loadAllKeys();
506
				
507
		// only contribute what are not already shared
508
		Iterator<Identifier> idIter = identifiers.iterator();
509
		while (idIter.hasNext()) {
510
			Identifier pid = idIter.next();
511
			if (idKeys.contains(pid)) {
512
				logMetacat.warn("Shared pid is already in local identifier set: " + pid.getValue());
513
				idKeys.remove(pid);
514
			}
515
		}
516
		logMetacat.warn("local pid count not yet shared: " + idKeys.size() + ", shared pid count: " + identifiers.size());
517

    
518
		//identifiers.addAll(idKeys);
519
		logMetacat.warn("Loading missing local keys into hzIdentifiers");
520
		for (Identifier key: idKeys) {
521
			if (!identifiers.contains(key)) {
522
				logMetacat.debug("Adding missing hzIdentifiers key: " + key.getValue());
523
				identifiers.add(key);
524
			}
525
		}
526
		logMetacat.warn("Initialized identifiers with missing local keys");
527
		
528
		logMetacat.warn("Processing SystemMetadata for shared pid count: " + identifiers.size());
529
		
530
		//loop through all the pids to find any null SM that needs to be synched
531
		Iterator<Identifier> sharedPids = identifiers.iterator();
532
		while (sharedPids.hasNext()) {
533
			Identifier pid = sharedPids.next();
534
			logMetacat.trace("looking up shared value for pid: " + pid.getValue());
535
			SystemMetadata sm = systemMetadata.get(pid);
536
			if (sm == null)  {
537
				logMetacat.warn("shared SystemMetadata for pid is null: " + pid.getValue());
538
				// look up owner of the pid
539
//				Partition partition = hzInstance.getPartitionService().getPartition(pid);
540
//				Member owner = partition.getOwner();
541
//				boolean isLocalPid = owner.localMember();
542
//				logMetacat.debug("owner of pid: " + pid.getValue() + " isLocal: " + isLocalPid);
543
				// if we don't own it, we can look it up locally in hopes that we have our own copy
544
				if (true) {
545
					// get directly from backing store
546
					try {
547
						sm = IdentifierManager.getInstance().getSystemMetadata(pid.getValue());
548
					} catch (McdbDocNotFoundException e) {
549
						// log and move on, there's nothing more we can do
550
						logMetacat.error("Could not find local SystemMetadata for pid: " + pid.getValue(), e);
551
						continue;
552
					}
553
				}
554
			}
555
			// check again, but hopefully we can add it to the map now (again) so that it is propgated to all listening members
556
			if (sm != null)  {
557
				logMetacat.debug("saving local SystemMetadata to shared map for pid: " + pid.getValue());
558
				systemMetadata.put(pid, sm);
559
			} else {
560
				logMetacat.error("local SystemMetadata is null for pid: " + pid.getValue());
561
			}
562
		}
563
		
564
	}
565
	
566
	private void resynchInThread() {
567
		logMetacat.debug("launching system metadata resynch in a thread");
568
		ExecutorService executor = Executors.newSingleThreadExecutor();
569
		executor.execute(new Runnable() {
570
			@Override
571
			public void run() {
572
				try {
573
					// this is a pull mechanism
574
					//resynch();
575
					// this is a push mechanism
576
					resynchToRemote();
577
				} catch (Exception e) {
578
					logMetacat.error("Error in resynchInThread: " + e.getMessage(), e);
579
				}
580
			}
581
		});
582
		executor.shutdown();
583
	}
584

    
585
	/**
586
	 * When there is missing SystemMetadata on the local member,
587
	 * we retrieve it from the shared map and add it to the local
588
	 * backing store for safe keeping.
589
	 */
590
	@Override
591
	public void memberAdded(MembershipEvent event) {
592
		Member member = event.getMember();
593
		logMetacat.debug("Member added to cluster: " + member.getInetSocketAddress());
594
		boolean isLocal = member.localMember();
595
		if (isLocal) {
596
			logMetacat.debug("Member islocal: " + member.getInetSocketAddress());
597
			synchronizeLocalStore();
598
		}
599
	}
600

    
601
	@Override
602
	public void memberRemoved(MembershipEvent event) {
603
		// TODO Auto-generated method stub
604
		
605
	}
606

    
607
	/**
608
	 * In cases where this cluster is paused, we want to 
609
	 * check that the local store accurately reflects the shared 
610
	 * SystemMetadata map
611
	 * @param event
612
	 */
613
	@Override
614
	public void stateChanged(LifecycleEvent event) {
615
		logMetacat.debug("HZ LifecycleEvent.state: " + event.getState());
616
		if (event.getState().equals(LifecycleEvent.LifecycleState.RESUMED)) {
617
			logMetacat.debug("HZ LifecycleEvent.state is RESUMED, calling synchronizeLocalStore()");
618
			synchronizeLocalStore();
619
		}
620
	}
621

    
622
	/**
623
	 * Load all System Metadata keys from the backing store
624
	 * @return set of pids
625
	 */
626
	private Set<Identifier> loadAllKeys() {
627

    
628
		Set<Identifier> pids = new HashSet<Identifier>();
629
		
630
		try {
631
			
632
			// ALTERNATIVE 1: this has more overhead than just looking at the GUIDs
633
//			ObjectList ol = IdentifierManager.getInstance().querySystemMetadata(
634
//					null, //startTime, 
635
//					null, //endTime, 
636
//					null, //objectFormatId, 
637
//					false, //replicaStatus, 
638
//					0, //start, 
639
//					-1 //count
640
//					);
641
//			for (ObjectInfo o: ol.getObjectInfoList()) {
642
//				Identifier pid = o.getIdentifier();
643
//				if ( !pids.contains(pid) ) {
644
//					pids.add(pid);
645
//				}				
646
//			}
647
			
648
			// ALTERNATIVE method: look up all the Identifiers from the table
649
			List<String> guids = IdentifierManager.getInstance().getAllSystemMetadataGUIDs();
650
			logMetacat.warn("Local SystemMetadata pid count: " + guids.size());
651
			for (String guid: guids){
652
				Identifier pid = new Identifier();
653
				pid.setValue(guid);
654
				pids.add(pid);
655
			}
656
			
657
		} catch (Exception e) {
658
			throw new RuntimeException(e.getMessage(), e);
659
			
660
		}
661
		
662
		return pids;
663
	}
664

    
665
}
(1-1/3)