Project

General

Profile

« Previous | Next » 

Revision 6468

catch runtime exceptions that arise from hazelcast storage errors in the system metadata map

View differences:

src/edu/ucsb/nceas/metacat/MetacatHandler.java
1857 1857
                  
1858 1858
                  // handle inserts
1859 1859
                  try {
1860
                	// create the system metadata  
1860 1861
                    sysMeta = createSystemMetadata(newdocid, user, groups);
1862
                    
1863
                    // save it to the map
1861 1864
                    HazelcastService.getInstance().getSystemMetadataMap().put(sysMeta.getIdentifier(), sysMeta);
1862 1865
                    
1863 1866
                  } catch ( McdbDocNotFoundException dnfe ) {
......
3003 3006
							
3004 3007
					        // manage it in the store
3005 3008
                            HazelcastService.getInstance().getSystemMetadataMap().put(sm.getIdentifier(), sm);
3006
                 
3007 3009
					        
3008 3010
                        } catch (Exception ee) {
3009 3011
                            // If the file did not exist before this method was 
......
3514 3516
      throws McdbException, McdbDocNotFoundException, SQLException, 
3515 3517
      IOException, AccessionNumberException, ClassNotFoundException,
3516 3518
      InsufficientKarmaException, ParseLSIDException, PropertyNotFoundException,
3517
      BaseException, NoSuchAlgorithmException, JiBXException
3519
      BaseException, NoSuchAlgorithmException, JiBXException, Exception
3518 3520
    {
3519 3521
      logMetacat.debug("MetacatHandler.createSystemMetadata() called.");
3520 3522
      logMetacat.debug("provided localId: " + localId);
......
3692 3694
                      }
3693 3695
                  
3694 3696
            		  // update the values
3695
                      HazelcastService.getInstance().getSystemMetadataMap().put(dataSysMeta.getIdentifier(), dataSysMeta);
3697
                     HazelcastService.getInstance().getSystemMetadataMap().put(dataSysMeta.getIdentifier(), dataSysMeta);
3696 3698
                  
3697 3699
                } catch ( McdbDocNotFoundException mdnf) {
3698 3700
                  mdnf.printStackTrace();
......
3736 3738
        } catch ( XPathExpressionException xpee ) {
3737 3739
          logMetacat.debug("There was a problem searching the EML document. " +
3738 3740
                           "The error message was: " + xpee.getMessage());
3739
        } catch ( Exception e ) {
3740
            logMetacat.debug("There was a problem creating System Metadata. " +
3741
                    "The error message was: " + e.getMessage());
3742
        } // end try()
3741
        } 
3743 3742
         
3744 3743
      } // end if()
3745 3744
      
src/edu/ucsb/nceas/metacat/dataone/CNodeService.java
145 145
    systemMetadata.setReplicationPolicy(policy);
146 146
    
147 147
    // update the metadata
148
    HazelcastService.getInstance().getSystemMetadataMap().lock(systemMetadata.getIdentifier());
149
    HazelcastService.getInstance().getSystemMetadataMap().put(systemMetadata.getIdentifier(), systemMetadata);
150
    HazelcastService.getInstance().getSystemMetadataMap().unlock(systemMetadata.getIdentifier());
151

  
148
    try {
149
	    HazelcastService.getInstance().getSystemMetadataMap().lock(systemMetadata.getIdentifier());
150
	    HazelcastService.getInstance().getSystemMetadataMap().put(systemMetadata.getIdentifier(), systemMetadata);
151
	    HazelcastService.getInstance().getSystemMetadataMap().unlock(systemMetadata.getIdentifier());
152
    } catch (Exception e) {
153
		throw new ServiceFailure("4882", e.getMessage());
154
	} finally {
155
	    HazelcastService.getInstance().getSystemMetadataMap().unlock(systemMetadata.getIdentifier());
156
	}
157
    
152 158
    return true;
153 159
  }
154 160

  
......
203 209
    systemMetadata.setReplicaList(replicas);
204 210
    
205 211
    // update the metadata
206
    HazelcastService.getInstance().getSystemMetadataMap().put(systemMetadata.getIdentifier(), systemMetadata);
207

  
212
    try {
213
	    HazelcastService.getInstance().getSystemMetadataMap().lock(systemMetadata.getIdentifier());
214
	    HazelcastService.getInstance().getSystemMetadataMap().put(systemMetadata.getIdentifier(), systemMetadata);
215
	    HazelcastService.getInstance().getSystemMetadataMap().unlock(systemMetadata.getIdentifier());
216
    } catch (Exception e) {
217
		throw new ServiceFailure("4700", e.getMessage());
218
	} finally {
219
	    HazelcastService.getInstance().getSystemMetadataMap().unlock(systemMetadata.getIdentifier());
220
	}
221
	
208 222
    return true;
209 223
  }
210 224

  
......
532 546
        sysmeta.setDateSysMetadataModified(new Date());
533 547
        try {
534 548
          HazelcastService.getInstance().getSystemMetadataMap().lock(sysmeta.getIdentifier());
535
        	HazelcastService.getInstance().getSystemMetadataMap().put(sysmeta.getIdentifier(), sysmeta);
549
          HazelcastService.getInstance().getSystemMetadataMap().put(sysmeta.getIdentifier(), sysmeta);
536 550
          HazelcastService.getInstance().getSystemMetadataMap().unlock(sysmeta.getIdentifier());
537
          
538 551
        } catch (Exception e) {
539 552
            throw new ServiceFailure("4862", "Error inserting system metadata: " + e.getClass() + ": " + e.getMessage());
540 553
        } finally {
......
596 609
        // update the system metadata into the object store
597 610
        logMetacat.debug("Starting to update SystemMetadata...");
598 611
        sysmeta.setDateSysMetadataModified(new Date());
599
        HazelcastService.getInstance().getSystemMetadataMap().put(sysmeta.getIdentifier(), sysmeta);
600 612
        
613
        // update system metadata
614
        try {
615
    	    HazelcastService.getInstance().getSystemMetadataMap().lock(sysmeta.getIdentifier());
616
    	    HazelcastService.getInstance().getSystemMetadataMap().put(sysmeta.getIdentifier(), sysmeta);
617
    	    HazelcastService.getInstance().getSystemMetadataMap().unlock(sysmeta.getIdentifier());
618
        } catch (Exception e) {
619
    		throw new ServiceFailure("4852", e.getMessage());
620
    	} finally {
621
    	    HazelcastService.getInstance().getSystemMetadataMap().unlock(sysmeta.getIdentifier());
622
    	}
623
        
601 624
        logMetacat.debug("Returning from updateSystemMetadata");
602 625
        EventLog.getInstance().log(null, session.getSubject().getValue(), guid.getValue(), "updateSystemMetadata");
603 626
        return true;
......
713 736
    systemMetadata.setRightsHolder(userId);
714 737
    
715 738
    // update the metadata
716
    HazelcastService.getInstance().getSystemMetadataMap().put(systemMetadata.getIdentifier(), systemMetadata);
717

  
739
    try {
740
	    HazelcastService.getInstance().getSystemMetadataMap().lock(systemMetadata.getIdentifier());
741
	    HazelcastService.getInstance().getSystemMetadataMap().put(systemMetadata.getIdentifier(), systemMetadata);
742
	    HazelcastService.getInstance().getSystemMetadataMap().unlock(systemMetadata.getIdentifier());
743
    } catch (Exception e) {
744
		throw new ServiceFailure("4490", e.getMessage());
745
	} finally {
746
	    HazelcastService.getInstance().getSystemMetadataMap().unlock(systemMetadata.getIdentifier());
747
	}
748
    
718 749
    return pid;
719 750
  }
720 751

  
......
758 789
	      break;
759 790
	        
760 791
      }
761
	     //lock, get, and unlock the pid
792
	    //lock, get, and unlock the pid
762 793
	    HazelcastService.getInstance().getSystemMetadataMap().lock(pid);
763
      sysmeta = HazelcastService.getInstance().getSystemMetadataMap().get(pid);
764
      HazelcastService.getInstance().getSystemMetadataMap().unlock(pid);
794
	    sysmeta = HazelcastService.getInstance().getSystemMetadataMap().get(pid);
795
	    HazelcastService.getInstance().getSystemMetadataMap().unlock(pid);
765 796
	    List<Replica> replicaList = sysmeta.getReplicaList();
766 797
	    
767 798
	    // find the replica with the status set to 'requested'
src/edu/ucsb/nceas/metacat/dataone/D1NodeService.java
242 242
    }
243 243

  
244 244
    // save the sysmeta
245
    HazelcastService.getInstance().getSystemMetadataMap().put(sysmeta.getIdentifier(), sysmeta);
245
    try {
246
    	HazelcastService.getInstance().getSystemMetadataMap().put(sysmeta.getIdentifier(), sysmeta);
247
    } catch (Exception e) {
248
        throw new ServiceFailure("1190", e.getMessage());
249
	}
246 250
    
247 251
    // setting the resulting identifier failed
248 252
    if (localId == null ) {
249 253
      throw new ServiceFailure("1190", "The Node is unable to create the object. ");
250 254
    }
251 255

  
252
    
253 256
    resultPid = pid;
254 257
    
255 258
    return resultPid;
......
551 554
    systemMetadata.setAccessPolicy(accessPolicy);
552 555
    
553 556
    // update the metadata
554
    HazelcastService.getInstance().getSystemMetadataMap().put(systemMetadata.getIdentifier(), systemMetadata);
555

  
557
    try {
558
    	HazelcastService.getInstance().getSystemMetadataMap().lock(systemMetadata.getIdentifier());
559
    	HazelcastService.getInstance().getSystemMetadataMap().put(systemMetadata.getIdentifier(), systemMetadata);
560
    	HazelcastService.getInstance().getSystemMetadataMap().unlock(systemMetadata.getIdentifier());
561
	} catch (Exception e) {
562
		throw new ServiceFailure("4430", e.getMessage());
563
	} finally {
564
		HazelcastService.getInstance().getSystemMetadataMap().unlock(systemMetadata.getIdentifier());
565
	}
566
    
556 567
    // TODO: how do we know if the map was persisted?
557 568
    success = true;
558 569
    
......
941 952
        sysmeta.getDateSysMetadataModified());
942 953

  
943 954
    //insert the system metadata
944
    HazelcastService.getInstance().getSystemMetadataMap().put(sysmeta.getIdentifier(), sysmeta);
945
      
955
    try {
956
    	HazelcastService.getInstance().getSystemMetadataMap().put(sysmeta.getIdentifier(), sysmeta);
957
    } catch (Exception e) {
958
        throw new ServiceFailure("1190", e.getMessage());
959
	}  
946 960
  }
947 961

  
948 962
  /**
......
955 969
      
956 970
    logMetacat.debug("D1NodeService.updateSystemMetadata() called.");
957 971
    sysMeta.setDateSysMetadataModified(new Date());
958
    HazelcastService.getInstance().getSystemMetadataMap().put(sysMeta.getIdentifier(), sysMeta);
972
    try {
973
    	HazelcastService.getInstance().getSystemMetadataMap().lock(sysMeta.getIdentifier());
974
    	HazelcastService.getInstance().getSystemMetadataMap().put(sysMeta.getIdentifier(), sysMeta);
975
    	HazelcastService.getInstance().getSystemMetadataMap().unlock(sysMeta.getIdentifier());
976
	} catch (Exception e) {
977
		throw new ServiceFailure("4862", e.getMessage());
978
	} finally {
979
		HazelcastService.getInstance().getSystemMetadataMap().unlock(sysMeta.getIdentifier());
980
	}
959 981
      
960 982
  }
961 983

  

Also available in: Unified diff