Project

General

Profile

« Previous | Next » 

Revision 7106

refactor memberAdded code to separate method - synchronizeLocalStore for possible reuse

View differences:

src/edu/ucsb/nceas/metacat/dataone/hazelcast/HazelcastService.java
447 447
		} catch (SQLException e) {
448 448
	      logMetacat.error("Could not save System Metadata to local store.", e);
449 449
	      
450
    } catch (InvalidSystemMetadata e) {
451
        logMetacat.error("Could not save System Metadata to local store.", e);
452
        
453
    }
450
	    } catch (InvalidSystemMetadata e) {
451
	        logMetacat.error("Could not save System Metadata to local store.", e);
452
	        
453
	    }
454 454
	}
455 455
	
456
	/**
457
	 * Checks the local backing store for missing SystemMetadata,
458
	 * retrieves those entries from the shared map if they exist,
459
	 * and saves them locally.
460
	 */
461
	private void synchronizeLocalStore() {
462
		List<String> localIds = IdentifierManager.getInstance().getLocalIdsWithNoSystemMetadata(true);
463
		if (localIds != null) {
464
			logMetacat.debug("Member missing SystemMetadata entries, count = " + localIds.size());
465
			for (String localId: localIds) {
466
				logMetacat.debug("Processing system metadata for localId: " + localId);
467
				try {
468
					String docid = DocumentUtil.getSmartDocId(localId);
469
					int rev = DocumentUtil.getRevisionFromAccessionNumber(localId);
470
					String guid = IdentifierManager.getInstance().getGUID(docid, rev);
471
					logMetacat.debug("Found mapped guid: " + guid);
472
					Identifier pid = new Identifier();
473
					pid.setValue(guid);
474
					SystemMetadata sm = systemMetadata.get(pid);
475
					logMetacat.debug("Found shared system metadata for guid: " + guid);
476
					saveLocally(sm);
477
					logMetacat.debug("Saved shared system metadata locally for guid: " + guid);
478
				} catch (Exception e) {
479
					logMetacat.error("Could not save shared SystemMetadata entry locally, localId: " + localId, e);
480
				}
481
			}
482
		}
483
	}
484
	
456 485
	public void resynch() throws Exception {
457 486
		
458 487
		// get the CN that is online
......
491 520
		boolean isLocal = member.localMember();
492 521
		if (isLocal) {
493 522
			logMetacat.debug("Member islocal: " + member.getInetSocketAddress());
494
			List<String> localIds = IdentifierManager.getInstance().getLocalIdsWithNoSystemMetadata(true);
495
			if (localIds != null) {
496
				logMetacat.debug("Member missing SystemMetadata entries, count = " + localIds.size());
497
				for (String localId: localIds) {
498
					logMetacat.debug("Processing system metadata for localId: " + localId);
499
					try {
500
						String docid = DocumentUtil.getSmartDocId(localId);
501
						int rev = DocumentUtil.getRevisionFromAccessionNumber(localId);
502
						String guid = IdentifierManager.getInstance().getGUID(docid, rev);
503
						logMetacat.debug("Found mapped guid: " + guid);
504
						Identifier pid = new Identifier();
505
						pid.setValue(guid);
506
						SystemMetadata sm = systemMetadata.get(pid);
507
						logMetacat.debug("Found shared system metadata for guid: " + guid);
508
						saveLocally(sm);
509
						logMetacat.debug("Saved shared system metadata locally for guid: " + guid);
510
					} catch (Exception e) {
511
						logMetacat.error("Could not save shared SystemMetadata entry locally, localId: " + localId, e);
512
					}
513
				}
514
			}
523
			synchronizeLocalStore();
515 524
		}
516 525
	}
517 526

  

Also available in: Unified diff