Project

General

Profile

« Previous | Next » 

Revision 10382

Added by Jing Tao over 6 years ago

Add the code to submit index task in every methods which modified the system metadata.

View differences:

src/edu/ucsb/nceas/metacat/dataone/CNodeService.java
148 148
          if(!isData) {
149 149
              String localId = IdentifierManager.getInstance().getLocalId(sysmeta.getIdentifier().getValue());
150 150
              objectURI = IdentifierManager.getInstance().getObjectFilePath(localId, isScienceMetadata(sysmeta));
151
              logMetacat.info("CNodeService.sbmitAddIndexTask - the URI for the object "+sysmeta.getIdentifier().getValue()+" is "+objectURI);
151 152
          }
152 153
          IndexTaskGenerator generator = new IndexTaskGenerator();
153 154
          //The objectURI will be null for data file
......
169 170
          }
170 171
          String localId = IdentifierManager.getInstance().getLocalId(sysmeta.getIdentifier().getValue());
171 172
          String objectURI = IdentifierManager.getInstance().getObjectFilePath(localId, isScienceMetadata(sysmeta));
173
          logMetacat.info("CNodeService.sbmitUpdateIndexTask - the URI for the object "+sysmeta.getIdentifier().getValue()+" is "+objectURI);
172 174
          IndexTaskGenerator generator = new IndexTaskGenerator();
173 175
          IndexTask task = generator.generateUpdateTask(sysmeta, objectURI);
174 176
          indexTaskClient.submit(task);
......
299 301
              systemMetadata.setSerialVersion(systemMetadata.getSerialVersion().add(BigInteger.ONE));
300 302
              systemMetadata.setDateSysMetadataModified(Calendar.getInstance().getTime());
301 303
              HazelcastService.getInstance().getSystemMetadataMap().put(systemMetadata.getIdentifier(), systemMetadata);
304
              //submit the index task
305
              String methodName ="setReplicationPolicy";
306
              submitUpdateIndexTask(systemMetadata, methodName);
302 307
              notifyReplicaNodes(systemMetadata);
303 308
              
304 309
          } catch (RuntimeException e) {
......
425 430
				//we don't need to update the modification date.
426 431
				//systemMetadata.setDateSysMetadataModified(Calendar.getInstance().getTime());
427 432
				HazelcastService.getInstance().getSystemMetadataMap().put(systemMetadata.getIdentifier(), systemMetadata);
433
				//submit the index task
434
	            String methodName ="deleteReplicationMetadata";
435
	            submitUpdateIndexTask(systemMetadata, methodName);
428 436
			} catch (RuntimeException e) {
429 437
				throw new ServiceFailure("4882", e.getMessage());
430 438
			}
......
506 514
      try {
507 515
          localId = IdentifierManager.getInstance().getLocalId(pid.getValue());
508 516
          super.delete(session, pid);
509
          
517
          //submit the index task
518
          String methodName="delete";
519
          submitDeleteIndexTask(systemMetadata, methodName);
510 520
      } catch (McdbDocNotFoundException e) {
511 521
          // This object is not registered in the identifier table. Assume it is of formatType DATA,
512 522
    	  // and set the archive flag. (i.e. the *object* doesn't exist on the CN)
......
526 536
	            //since this is cn, we don't need worry about the mn solr index.
527 537
	            HazelcastService.getInstance().getSystemMetadataMap().remove(pid);
528 538
	            HazelcastService.getInstance().getIdentifiers().remove(pid);
539
	            //submit the index task
540
	            String methodName="delete";
541
	            submitDeleteIndexTask(sysMeta, methodName);
529 542
	            String username = session.getSubject().getValue();//just for logging purpose
530 543
                //since data objects were not registered in the identifier table, we use pid as the docid
531 544
                EventLog.getInstance().log(request.getRemoteAddr(), request.getHeader("User-Agent"), username, pid.getValue(), Event.DELETE.xmlValue());
......
555 568
          throw new ServiceFailure("4962", "Couldn't delete " + pid.getValue() + 
556 569
                  ". The local id of the object with the identifier can't be identified since " + e.getMessage());
557 570
      }
571
      
558 572

  
559 573
      // get the node list
560 574
      try {
......
717 731
                  throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, NotImplemented {
718 732
          boolean logArchive = true;
719 733
          archiveCNObject(logArchive, session, pid, sysMeta, needModifyDate);
734
          //submit the delete index task
735
          String methodName = "archive";
736
          submitDeleteIndexTask(sysMeta, methodName);
720 737
          // notify the replicas
721 738
          notifyReplicaNodes(sysMeta);
722 739
          return pid;
......
843 860
			} catch (RuntimeException e) {
844 861
				throw new ServiceFailure("4882", e.getMessage());
845 862
			}
846
			
863
			//submit an update index task
864
			String methodName="setObsoletedBy";
865
			submitUpdateIndexTask(systemMetadata, methodName);
847 866

  
848 867
		} catch (RuntimeException e) {
849 868
			throw new ServiceFailure("4882", e.getMessage());
......
1063 1082
              // update the modified date for changes to the replica list
1064 1083
              //systemMetadata.setDateSysMetadataModified(Calendar.getInstance().getTime());
1065 1084
              HazelcastService.getInstance().getSystemMetadataMap().put(systemMetadata.getIdentifier(), systemMetadata);
1085
              
1086
              //submit the index task
1087
              String methodName ="setReplicationStatus";
1088
              submitUpdateIndexTask(systemMetadata, methodName);
1066 1089

  
1067 1090
              if ( !status.equals(ReplicationStatus.QUEUED) && 
1068 1091
            	   !status.equals(ReplicationStatus.REQUESTED)) {
......
1527 1550

  
1528 1551
      
1529 1552
      logMetacat.debug("Returning from registerSystemMetadata");
1553
      //submit the index task
1554
      String methodName="registerSystemMetadata";
1555
      boolean isData = true;
1556
      submitAddIndexTask(sysmeta, methodName, isData);
1530 1557
      
1531 1558
      try {
1532 1559
    	  String localId = IdentifierManager.getInstance().getLocalId(pid.getValue());
......
1708 1735
              systemMetadata.setSerialVersion(systemMetadata.getSerialVersion().add(BigInteger.ONE));
1709 1736
              systemMetadata.setDateSysMetadataModified(Calendar.getInstance().getTime());
1710 1737
              HazelcastService.getInstance().getSystemMetadataMap().put(pid, systemMetadata);
1738
              //submit the index task
1739
              String methodName ="setRightsHolder";
1740
              submitUpdateIndexTask(systemMetadata, methodName);
1711 1741
              notifyReplicaNodes(systemMetadata);
1712 1742
              
1713 1743
          } catch (RuntimeException e) {
......
2064 2094
              systemMetadata.setSerialVersion(systemMetadata.getSerialVersion().add(BigInteger.ONE));
2065 2095
              systemMetadata.setDateSysMetadataModified(Calendar.getInstance().getTime());
2066 2096
              HazelcastService.getInstance().getSystemMetadataMap().put(systemMetadata.getIdentifier(), systemMetadata);
2097
              //submit the index task
2098
              String methodName ="setAccessPolicy";
2099
              submitUpdateIndexTask(systemMetadata, methodName);
2067 2100
              notifyReplicaNodes(systemMetadata);
2068 2101
              
2069 2102
          } catch (RuntimeException e) {
......
2202 2235
              //systemMetadata.setDateSysMetadataModified(Calendar.getInstance().getTime());
2203 2236
              HazelcastService.getInstance().getSystemMetadataMap().put(systemMetadata.getIdentifier(), systemMetadata);
2204 2237
              
2238
              //submit the index task
2239
              String methodName ="updateReplicationMetadata";
2240
              submitUpdateIndexTask(systemMetadata, methodName);
2241
              
2205 2242
              // inform replica nodes of the change if the status is complete
2206 2243
              if ( replicaStatus.equals(ReplicationStatus.COMPLETED) ) {
2207 2244
            	  notifyReplicaNodes(systemMetadata);
......
2383 2420
        boolean needUpdateModificationDate = false;//cn doesn't need to change the modification date.
2384 2421
        boolean fromCN = true;
2385 2422
        success = updateSystemMetadata(session, pid, sysmeta, needUpdateModificationDate, currentSysmeta, fromCN);
2423
        //submit the index task
2424
        String methodName="updateSystemMetadata";
2425
        submitUpdateIndexTask(sysmeta, methodName);
2386 2426
    } finally {
2387 2427
        HazelcastService.getInstance().getSystemMetadataMap().unlock(pid);
2388 2428
    }

Also available in: Unified diff