Project

General

Profile

« Previous | Next » 

Revision 9354

Added by Jing Tao over 8 years ago

Add the case the mn.updateSystemMetadata and cn.updateSystemMetadata will call the archive method internally.

View differences:

CNodeService.java
595 595
          HazelcastService.getInstance().getSystemMetadataMap().lock(pid);
596 596
          logMetacat.debug("CNodeService.archive - lock the system metadata for "+pid.getValue());
597 597
          SystemMetadata sysMeta = HazelcastService.getInstance().getSystemMetadataMap().get(pid);
598
          boolean notifyReplica = true;
599
          archiveCNObject(session, pid, sysMeta, notifyReplica);
598
          boolean needModifyDate = true;
599
          archiveCNObjectWithNotificationReplica(session, pid, sysMeta, needModifyDate);
600 600
      
601 601
      } finally {
602 602
          HazelcastService.getInstance().getSystemMetadataMap().unlock(pid);
......
609 609
  
610 610
  
611 611
  /**
612
   * Archive a object on cn. This method doesn't lock the system metadata map. The caller should lock it.
612
   * Archive a object on cn and notify the replica. This method doesn't lock the system metadata map. The caller should lock it.
613 613
   * This method doesn't check the authorization; this method only accept a pid.
614 614
   * @param session
615 615
   * @param pid
......
622 622
   * @throws NotFound
623 623
   * @throws NotImplemented
624 624
   */
625
  public Identifier archiveCNObject(Session session, Identifier pid, SystemMetadata sysMeta, boolean notifyReplica) 
626
          throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, NotImplemented {
627

  
628
          String localId = null; // The corresponding docid for this pid
629
          
630
          // Check for the existing identifier
631
          try {
632
              localId = IdentifierManager.getInstance().getLocalId(pid.getValue());
633
              super.archiveObject(session, pid, sysMeta);
634
          
635
          } catch (McdbDocNotFoundException e) {
636
              // This object is not registered in the identifier table. Assume it is of formatType DATA,
637
              // and set the archive flag. (i.e. the *object* doesn't exist on the CN)
638
              
639
              try {
640
                  if ( sysMeta != null ) {
641
                    sysMeta.setSerialVersion(sysMeta.getSerialVersion().add(BigInteger.ONE));
642
                    sysMeta.setArchived(true);
643
                    sysMeta.setDateSysMetadataModified(Calendar.getInstance().getTime());
644
                    HazelcastService.getInstance().getSystemMetadataMap().put(pid, sysMeta);
645
                      
646
                  } else {
647
                      throw new ServiceFailure("4972", "Couldn't archive the object " + pid.getValue() +
648
                          ". Couldn't obtain the system metadata record.");
649
                      
650
                  }
651
                  
652
              } catch (RuntimeException re) {
653
                  throw new ServiceFailure("4972", "Couldn't archive " + pid.getValue() + 
654
                      ". The error message was: " + re.getMessage());
655
                  
656
              } 
657

  
658
          } catch (SQLException e) {
659
              throw new ServiceFailure("4972", "Couldn't archive the object " + pid.getValue() +
660
                      ". The local id of the object with the identifier can't be identified since "+e.getMessage());
661
          }
662
          if(notifyReplica) {
663
              // notify the replicas
664
              notifyReplicaNodes(sysMeta);
665
          }
625
  private Identifier archiveCNObjectWithNotificationReplica(Session session, Identifier pid, SystemMetadata sysMeta, boolean needModifyDate) 
626
                  throws InvalidToken, ServiceFailure, NotAuthorized, NotFound, NotImplemented {
627
          archiveCNObject(session, pid, sysMeta, needModifyDate);
628
          // notify the replicas
629
          notifyReplicaNodes(sysMeta);
666 630
          return pid;
667
          
668 631
    }
669 632
  
670 633
  
......
2270 2233
        List<Replica> replicas = currentSysmeta.getReplicaList();
2271 2234
        sysmeta.setReplicaList(replicas);
2272 2235
        boolean needUpdateModificationDate = false;//cn doesn't need to change the modification date.
2273
        success = updateSystemMetadata(session, pid, sysmeta, needUpdateModificationDate, currentSysmeta);
2236
        boolean fromCN = true;
2237
        success = updateSystemMetadata(session, pid, sysmeta, needUpdateModificationDate, currentSysmeta, fromCN);
2274 2238
    } finally {
2275 2239
        HazelcastService.getInstance().getSystemMetadataMap().unlock(pid);
2276 2240
    }

Also available in: Unified diff