Project

General

Profile

« Previous | Next » 

Revision 6703

When using ILock.lock(), get a lock on the string value of the Identifier, not the Identifier object itself. Hazelcast locking won't work otherwise.

View differences:

src/edu/ucsb/nceas/metacat/dataone/CNodeService.java
139 139
      
140 140
      SystemMetadata systemMetadata = null;
141 141
      try {
142
          lock = HazelcastService.getInstance().getLock(pid);
142
          lock = HazelcastService.getInstance().getLock(pid.getValue());
143 143
          lock.lock();
144 144
          systemMetadata = HazelcastService.getInstance().getSystemMetadataMap().get(pid);
145 145
        
......
214 214
      
215 215
      SystemMetadata systemMetadata = null;
216 216
      try {      
217
          lock = HazelcastService.getInstance().getLock(pid);
217
          lock = HazelcastService.getInstance().getLock(pid.getValue());
218 218
          lock.lock();
219 219
          systemMetadata = HazelcastService.getInstance().getSystemMetadataMap().get(pid);
220 220

  
......
361 361
    
362 362
    SystemMetadata systemMetadata = null;
363 363
    try {
364
        lock = HazelcastService.getInstance().getLock(pidOfSubject);
364
        lock = HazelcastService.getInstance().getLock(pidOfSubject.getValue());
365 365
        lock.lock();
366 366
        systemMetadata = HazelcastService.getInstance().getSystemMetadataMap().get(pidOfSubject);
367 367
        
......
440 440
    Checksum checksum = null;
441 441
    
442 442
    try {
443
        lock = HazelcastService.getInstance().getLock(pid);
443
        lock = HazelcastService.getInstance().getLock(pid.getValue());
444 444
        lock.lock();
445 445
        systemMetadata = HazelcastService.getInstance().getSystemMetadataMap().get(pid);
446 446
        checksum = systemMetadata.getChecksum();
......
681 681
      // insert the system metadata into the object store
682 682
      logMetacat.debug("Starting to insert SystemMetadata...");
683 683
      try {
684
          lock = HazelcastService.getInstance().getLock(sysmeta.getIdentifier());
684
          lock = HazelcastService.getInstance().getLock(sysmeta.getIdentifier().getValue());
685 685
          sysmeta.setSerialVersion(BigInteger.ONE);
686 686
          sysmeta.setDateSysMetadataModified(Calendar.getInstance().getTime());
687 687
          HazelcastService.getInstance().getSystemMetadataMap().put(sysmeta.getIdentifier(), sysmeta);
......
806 806
      
807 807
      SystemMetadata systemMetadata = null;
808 808
      try {
809
          lock = HazelcastService.getInstance().getLock(pid);
809
          lock = HazelcastService.getInstance().getLock(pid.getValue());
810 810
          systemMetadata = HazelcastService.getInstance().getSystemMetadataMap().get(pid);
811 811
          
812 812
          // does the request have the most current system metadata?
......
900 900
          
901 901
      }
902 902
      //lock, get, and unlock the pid
903
      lock = HazelcastService.getInstance().getLock(pid);
903
      lock = HazelcastService.getInstance().getLock(pid.getValue());
904 904
      lock.lock();
905 905
      logMetacat.debug("Getting system metadata for identifier " + pid.getValue());
906 906
      
......
1005 1005
          // proceed if we're called by a CN
1006 1006
          if ( isAllowed ) {
1007 1007
              // create the coordinating node version of the document      
1008
              lock = HazelcastService.getInstance().getLock(pid);
1008
              lock = HazelcastService.getInstance().getLock(pid.getValue());
1009 1009
              lock.lock();
1010 1010
              sysmeta.setSerialVersion(BigInteger.ONE);
1011 1011
              sysmeta.setDateSysMetadataModified(Calendar.getInstance().getTime());
......
1070 1070
      
1071 1071
      SystemMetadata systemMetadata = null;
1072 1072
      try {
1073
          lock = HazelcastService.getInstance().getLock(pid);
1073
          lock = HazelcastService.getInstance().getLock(pid.getValue());
1074 1074
          lock.lock();
1075 1075
          systemMetadata = HazelcastService.getInstance().getSystemMetadataMap().get(pid);
1076 1076

  
......
1154 1154

  
1155 1155
      SystemMetadata systemMetadata = null;
1156 1156
      try {      
1157
          lock = HazelcastService.getInstance().getLock(pid);
1157
          lock = HazelcastService.getInstance().getLock(pid.getValue());
1158 1158
          lock.lock();
1159 1159
          systemMetadata = HazelcastService.getInstance().getSystemMetadataMap().get(pid);
1160 1160

  
src/edu/ucsb/nceas/metacat/dataone/hazelcast/HazelcastService.java
218 218
   * Get the system metadata map
219 219
   * 
220 220
   * @return systemMetadata - the hazelcast map of system metadata
221
   * @param identifier - the identifier of the object as a string
221 222
   */
222 223
  public IMap<Identifier,SystemMetadata> getSystemMetadataMap() {
223 224
	  return systemMetadata;
224 225
  }
225 226

  
226
  public ILock getLock(Identifier identifier) {
227
  public ILock getLock(String identifier) {
227 228
    
228 229
    ILock lock = null;
229 230
    
......
232 233
        
233 234
    } catch (RuntimeException e) {
234 235
        logMetacat.info("Couldn't get a lock for identifier " + 
235
            identifier.getValue() + " !!");
236
            identifier + " !!");
236 237
    }
237 238
    return lock;
238 239
      

Also available in: Unified diff