public void installSnapshot(SnapshotReader reader) {
    log.debug("Installing snapshot {}", reader.snapshot().index());
    reader.skip(Bytes.LONG); // Skip the service ID
    PrimitiveType primitiveType;
    try {
      primitiveType = raft.getPrimitiveTypes().getPrimitiveType(reader.readString());
    } catch (ConfigurationException e) {
      log.error(e.getMessage(), e);
      return;
    }

    String serviceName = reader.readString();
    currentIndex = reader.readLong();
    currentTimestamp = reader.readLong();
    timestampDelta = reader.readLong();

    int sessionCount = reader.readInt();
    for (int i = 0; i < sessionCount; i++) {
      SessionId sessionId = SessionId.from(reader.readLong());
      MemberId node = MemberId.from(reader.readString());
      ReadConsistency readConsistency = ReadConsistency.valueOf(reader.readString());
      long minTimeout = reader.readLong();
      long maxTimeout = reader.readLong();
      long sessionTimestamp = reader.readLong();

      // Only create a new session if one does not already exist. This is necessary to ensure only a single session
      // is ever opened and exposed to the state machine.
      RaftSession session = raft.getSessions().addSession(new RaftSession(
          sessionId,
          node,
          serviceName,
          primitiveType,
          readConsistency,
          minTimeout,
          maxTimeout,
          sessionTimestamp,
          service.serializer(),
          this,
          raft,
          threadContextFactory));

      session.setRequestSequence(reader.readLong());
      session.setCommandSequence(reader.readLong());
      session.setEventIndex(reader.readLong());
      session.setLastCompleted(reader.readLong());
      session.setLastApplied(reader.snapshot().index());
      session.setLastUpdated(sessionTimestamp);
      session.open();
      service.register(sessions.addSession(session));
    }
    service.restore(new DefaultBackupInput(reader, service.serializer()));
  }
public void installSnapshot ( SnapshotReader reader ) { log . debug ( "Installing snapshot {}" , reader . snapshot ( ) . index ( ) ) ; reader . skip ( Bytes . LONG ) ; PrimitiveType primitiveType ; try { primitiveType = raft . getPrimitiveTypes ( ) . getPrimitiveType ( reader . readString ( ) ) ; } catch ( ConfigurationException e ) { log . error ( e . getMessage ( ) , e ) ; return ; } String serviceName = reader . readString ( ) ; currentIndex = reader . readLong ( ) ; currentTimestamp = reader . readLong ( ) ; timestampDelta = reader . readLong ( ) ; int sessionCount = reader . readInt ( ) ; for ( int i = 0 ; i < sessionCount ; i ++ ) { SessionId sessionId = SessionId . from ( reader . readLong ( ) ) ; MemberId node = MemberId . from ( reader . readString ( ) ) ; ReadConsistency readConsistency = ReadConsistency . valueOf ( reader . readString ( ) ) ; long minTimeout = reader . readLong ( ) ; long maxTimeout = reader . readLong ( ) ; long sessionTimestamp = reader . readLong ( ) ; RaftSession session = raft . getSessions ( ) . addSession ( new RaftSession ( sessionId , node , serviceName , primitiveType , readConsistency , minTimeout , maxTimeout , sessionTimestamp , service . serializer ( ) , this , raft , threadContextFactory ) ) ; session . setRequestSequence ( reader . readLong ( ) ) ; session . setCommandSequence ( reader . readLong ( ) ) ; session . setEventIndex ( reader . readLong ( ) ) ; session . setLastCompleted ( reader . readLong ( ) ) ; session . setLastApplied ( reader . snapshot ( ) . index ( ) ) ; session . setLastUpdated ( sessionTimestamp ) ; session . open ( ) ; service . register ( sessions . addSession ( session ) ) ; } service . restore ( new DefaultBackupInput ( reader , service . serializer ( ) ) ) ; }
Installs a snapshot.