Recover from start sync operation.

@param uri uri to start sync
@param mountId mount id of the uri
547133
public void recoverFromStartSync(AlluxioURI uri, long mountId) {
    // if the init sync has been launched, we need to stop it
    if (mSyncPathStatus.containsKey(uri)) {
      Future<?> syncFuture = mSyncPathStatus.remove(uri);
      if (syncFuture != null) {
        syncFuture.cancel(true);
      }
    }

    // if the polling thread has been launched, we need to stop it
    mFilterMap.remove(mountId);
    Future<?> future = mPollerMap.remove(mountId);
    if (future != null) {
      future.cancel(true);
    }
  }
761169
public void loadSnapshot(String vm, String snapshotUuid) {
        if (!EnumSet.of(POWEROFF, SAVED).contains(vmState(vm))) {
            powerOff(vm);
        }
        execute("snapshot", vm, "restore", snapshotUuid);
        start(vm);
    }
660114
protected void afterRestart(final Throwable reason) {
    // override for specific recovery

    logger().log("Default after restart recovery after: " + reason.getMessage(), reason);

    lifeCycle.beforeStart(this);
  }
1009865
final protected void restore() throws RepositoryRestoreExeption
   {
      try
      {
         stateRestore = REPOSITORY_RESTORE_STARTED;
         startTime = Calendar.getInstance();

         restoreRepository();

         stateRestore = REPOSITORY_RESTORE_SUCCESSFUL;
         endTime = Calendar.getInstance();
      }
      catch (Throwable t) //NOSONAR
      {
         stateRestore = REPOSITORY_RESTORE_FAIL;
         restoreException = t;

         throw new RepositoryRestoreExeption(t.getMessage(), t);
      }
      finally
      {
         if (removeJobOnceOver)
         {
            backupManager.restoreRepositoryJobs.remove(this);
         }  
      }
   }
599178
public static br_restart restart(nitro_service client, br_restart resource) throws Exception
	{
		return ((br_restart[]) resource.perform_operation(client, "restart"))[0];
	}
736267
public boolean restart(final String configId, final Password password) throws IOException, ServletException {
	if (!singelton.can(CFMLEngine.CAN_RESTART_CONTEXT, password))// TODO restart single context
	    throw new IOException("access denied to restart CFML Context (configId:" + configId + ")");

	return _restart();
    }
979263
public UfsManager.UfsClient getUfsClient(long mountId) {
    try {
      return mUfsManager.get(mountId);
    } catch (NotFoundException | UnavailableException e) {
      LOG.warn("failed to get ufsclient for mountid {}, exception {}", mountId, e);
    }
    return null;
  }
579682
public void fail(String requestId) throws TException
    {
        int index = this.requestedMap.remove(requestId);
        DRPCInvocationsClient client = this.clients.get(index);
        client.failRequest(requestId);
    }
1258048
public void updateServiceUri(String serviceName, String providerId,
            String uri) {
        getServiceDirectoryClient().updateServiceInstanceUri(serviceName, providerId, uri);
    }
487331
public void startSyncPostJournal(AlluxioURI uri) throws InvalidPathException {
    MountTable.Resolution resolution = mMountTable.resolve(uri);
    startInitSync(uri, resolution);
    launchPollingThread(resolution.getMountId(), SyncInfo.INVALID_TXID);
  }
168638
public final void removeServlet(String mountPoint) {
        mountPoint = GenericContext.normalizeMountPoint(mountPoint);
        synchronized (servlets) {
            ServletDescriptor remove = servlets.remove(mountPoint);
            if (remove != null) {
                unregisterServletDescriptor(remove);
            }
        }

    }
551887
public boolean recoverTransitionRead(StartupOption startOpt)
      throws IOException {
    
    FLOG.info("Startup: recovering namenode storage");
    
    assert startOpt != StartupOption.FORMAT : 
      "NameNode formatting should be performed before reading the image";
    
    Collection<File> imageDirs = storage.getImageDirectories();

    // none of the data dirs exist
    if(imageDirs.size() == 0 && startOpt != StartupOption.IMPORT)  
      throw new IOException(
          "All specified directories are not accessible or do not exist.");
    editLog.checkJournals();
    
    storage.setUpgradeManager(namesystem.upgradeManager);
    
    Map<ImageManager, RemoteStorageState> remoteImageStates = Maps.newHashMap();
    Map<JournalManager, RemoteStorageState> remoteJournalStates = Maps.newHashMap();

    List<ImageManager> nonFileImageManagers = getNonFileImageManagers();
    List<JournalManager> nonFileJournalManagers = getNonFileJournalManagers();

    updateRemoteStates(remoteImageStates, remoteJournalStates,
        nonFileImageManagers, nonFileJournalManagers);
    
    // number of non-file storage locations
    int nonFileStorageLocations = nonFileImageManagers.size()
        + nonFileJournalManagers.size();
    
    FLOG.info("Startup: checking storage directory state.");
    // 1. For each data directory calculate its state and 
    // check whether all is consistent before transitioning.
    Map<StorageDirectory, StorageState> dataDirStates = 
             new HashMap<StorageDirectory, StorageState>();
    boolean isFormatted = recoverStorageDirs(startOpt, dataDirStates);
    
    // Recover the non-file storage locations.
    editLog.transitionNonFileJournals(null, false,
        Transition.RECOVER, startOpt);
    imageSet.transitionNonFileImages(null, false, Transition.RECOVER,
        startOpt);

    if (!isFormatted && startOpt != StartupOption.ROLLBACK 
                     && startOpt != StartupOption.IMPORT) {
      for(Entry<StorageDirectory, StorageState> e : dataDirStates.entrySet()) {
        LOG.info("State : " + e.getKey().getCurrentDir() + " state: " +e.getValue());
      }
      throw new IOException("NameNode is not formatted." + dataDirStates);      
    }


    int layoutVersion = storage.getLayoutVersion();
    if (layoutVersion < Storage.LAST_PRE_UPGRADE_LAYOUT_VERSION) {
      NNStorage.checkVersionUpgradable(storage.getLayoutVersion());
    }
    if (startOpt != StartupOption.UPGRADE
        && layoutVersion < Storage.LAST_PRE_UPGRADE_LAYOUT_VERSION
        && layoutVersion != FSConstants.LAYOUT_VERSION) {
      throw new IOException(
          "\nFile system image contains an old layout version " 
          + storage.getLayoutVersion() + ".\nAn upgrade to version "
          + FSConstants.LAYOUT_VERSION + " is required.\n"
          + "Please restart NameNode with -upgrade option.");
    }
       
    editLog.updateNamespaceInfo(storage);

    // check whether distributed upgrade is required and/or should be continued
    storage.verifyDistributedUpgradeProgress(startOpt);

    FLOG.info("Startup: formatting unformatted directories.");
    
    // 2. Format unformatted dirs.
    for (Iterator<StorageDirectory> it = storage.dirIterator(); it.hasNext();) {
      StorageDirectory sd = it.next();
      StorageState curState = dataDirStates.get(sd);
      switch(curState) {
      case NON_EXISTENT:
        throw new IOException(StorageState.NON_EXISTENT + 
                              " state cannot be here");
      case NOT_FORMATTED:        
        LOG.info("Storage directory " + sd.getRoot() + " is not formatted.");
        if (!sd.isEmpty()) {
          LOG.error("Storage directory " + sd.getRoot()
            + " is not empty, and will not be formatted! Exiting.");
          throw new IOException(
            "Storage directory " + sd.getRoot() + " is not empty!");
        }   
        LOG.info("Formatting ...");
        sd.clearDirectory(); // create empty currrent dir
        break;
      default:
        break;
      }
    }
    
    // check non-file images
    for (Entry<ImageManager, RemoteStorageState> e : remoteImageStates
        .entrySet()) {
      checkAllowedNonFileState(e.getValue().getStorageState(), e.getKey());
    }
    // check non-file journals
    for (Entry<JournalManager, RemoteStorageState> e : remoteJournalStates
        .entrySet()) {
      checkAllowedNonFileState(e.getValue().getStorageState(), e.getKey());
    }  

    FLOG.info("Startup: Transitions.");
    // 3. Do transitions
    switch(startOpt) {
    case UPGRADE:
      doUpgrade();
      return false; // upgrade saved image already
    case IMPORT:
      doImportCheckpoint();
      if (nonFileStorageLocations > 0) {
        throwIOException("Import not supported for non-file storage");
      }
      return false; // import checkpoint saved image already
    case ROLLBACK:
      doRollback(remoteImageStates, remoteJournalStates);
      // Update the states since the remote states have changed after rollback.
      updateRemoteStates(remoteImageStates, remoteJournalStates,
          nonFileImageManagers, nonFileJournalManagers);
      InjectionHandler.processEvent(InjectionEvent.FSIMAGE_ROLLBACK_DONE);
      break;
    case REGULAR:
      // just load the image
    }
    
    if (inUpgradeStatus()) {
      namesystem.setUpgradeStartTime(FSNamesystem.now());
    }
    
    // final consistency check for non-file images and journals
    // read version file first
    FSImageStorageInspector inspector = storage.readAndInspectDirs();
    
    FLOG.info("Startup: starting with storage info: " + storage.toColonSeparatedString());
    
    // format unformatted journals and images
    // check if the formatted ones are consistent with local storage
    for (Entry<ImageManager, RemoteStorageState> e : remoteImageStates
        .entrySet()) {
      if (e.getValue().getStorageState() != StorageState.NORMAL) {
        LOG.info("Formatting remote image: " + e.getKey());
        e.getKey().transitionImage(storage, Transition.FORMAT, null);
      } else {
        checkConsistency(e.getValue().getStorageInfo(), storage, true, e.getKey());
      }
    } 
    for (Entry<JournalManager, RemoteStorageState> e : remoteJournalStates
        .entrySet()) {
      if (e.getValue().getStorageState() != StorageState.NORMAL) {
        LOG.info("Formatting remote journal: " + e.getKey());
        e.getKey().transitionJournal(storage, Transition.FORMAT, null);
      } else {
        checkConsistency(e.getValue().getStorageInfo(), storage, true, e.getKey());
      }
    }

    // load the image
    return loadFSImage(inspector);
  }
646282
public void restart(String workflowId, boolean useLatestDefinitions) {
        Preconditions.checkArgument(StringUtils.isNotBlank(workflowId), "workflow id cannot be blank");
        stub.restartWorkflow(WorkflowServicePb.RestartWorkflowRequest.newBuilder()
                .setWorkflowId(workflowId)
                .setUseLatestDefinitions(useLatestDefinitions)
                .build()
        );
    }
979943
public boolean restartApp(int appId) {
    if (appId == -1) {
      // TODO (nlu): implement restart all
      String message = "Restarting the whole topology is not supported yet. "
          + "Please kill and resubmit the topology.";
      LOG.log(Level.SEVERE, message);
      return false;
    }

    // Setup Connection
    String restartRequest = String.format("%s/v2/apps/%s/%d/restart",
        this.marathonURI, this.topologyName, appId);
    HttpURLConnection conn = NetworkUtils.getHttpConnection(restartRequest);

    if (this.marathonAuthToken != null) {
      conn.setRequestProperty("Authorization", String.format("token=%s", this.marathonAuthToken));
    }

    if (conn == null) {
      LOG.log(Level.SEVERE, "Failed to find marathon scheduler");
      return false;
    }

    try {
      // send post request to restart app
      byte[] empty = new byte[0];
      if (!NetworkUtils.sendHttpPostRequest(conn, NetworkUtils.JSON_TYPE, empty)) {
        LOG.log(Level.SEVERE, "Failed to send post request");
        return false;
      }

      // Check response
      boolean success = NetworkUtils.checkHttpResponseCode(conn, HttpURLConnection.HTTP_OK);

      if (success) {
        LOG.log(Level.INFO, "Successfully restarted container {0}", appId);
        return true;
      } else if (NetworkUtils.checkHttpResponseCode(conn, HttpURLConnection.HTTP_UNAUTHORIZED)) {
        LOG.log(Level.SEVERE, "Marathon requires authentication");
        return false;
      } else {
        LOG.log(Level.SEVERE, "Failed to restart container {0}", appId);
        return false;
      }
    } finally {
      // Disconnect to release resources
      conn.disconnect();
    }
  }
1268235
@SuppressWarnings("restriction")
	public static void mountOrientDbRestApi(OrientDBHttpAPIResource resource, WebApplication app) {
		mountOrientDbRestApi(resource, app, MOUNT_PATH);
	}
1037488
public void start(int restartableId) {
        stop(restartableId);
        requested.add(restartableId);
        restartableSubscriptions.put(restartableId, restartables.get(restartableId).call());
    }
1206339
protected void onBackupWithoutLoadedSession( @Nonnull final String sessionId, @Nonnull final String requestId,
            @Nonnull final BackupSessionService backupSessionService ) {

        if ( !_sessionIdFormat.isValid( sessionId ) ) {
            return;
        }

        try {

            final long start = System.currentTimeMillis();

            final String validityKey = _sessionIdFormat.createValidityInfoKeyName( sessionId );
            final SessionValidityInfo validityInfo = loadSessionValidityInfoForValidityKey( validityKey );
            if ( validityInfo == null ) {
                _log.warn( "Found no validity info for session id " + sessionId );
                return;
            }

            final int maxInactiveInterval = validityInfo.getMaxInactiveInterval();
            final byte[] validityData = encode( maxInactiveInterval, System.currentTimeMillis(),
                    System.currentTimeMillis() );
            // fix for #88, along with the change in session.getMemcachedExpirationTimeToSet
            final int expiration = maxInactiveInterval <= 0 ? 0 : maxInactiveInterval;
            final Future<Boolean> validityResult = _storage.set( validityKey, toMemcachedExpiration(expiration), validityData );
            if ( !_manager.isSessionBackupAsync() ) {
                validityResult.get( _manager.getSessionBackupTimeout(), TimeUnit.MILLISECONDS );
            }

            /*
             * - ping session
             * - ping session backup
             * - save validity backup
             */
            final Callable<?> backupSessionTask = new OnBackupWithoutLoadedSessionTask( sessionId,
                    _storeSecondaryBackup, validityKey, validityData, maxInactiveInterval );
            _executor.submit( backupSessionTask );

            if ( _log.isDebugEnabled() ) {
                _log.debug( "Stored session validity info for session " + sessionId );
            }

            _stats.registerSince( NON_STICKY_ON_BACKUP_WITHOUT_LOADED_SESSION, start );

        } catch( final Throwable e ) {
            _log.warn( "An error when trying to load/update validity info.", e );
        }

    }