Initialize lease recovery for this object
765760
void assignPrimaryDatanode() {
    //assign the first alive datanode as the primary datanode

    if (targets.length == 0) {
      NameNode.stateChangeLog.warn("BLOCK*"
        + " INodeFileUnderConstruction.initLeaseRecovery:"
        + " No blocks found, lease removed.");
    }

    int previous = primaryNodeIndex;
    Block lastBlock = this.getLastBlock();
    // find an alive datanode beginning from previous.
    // This causes us to cycle through the targets on successive retries.
    for(int i = 1; i <= targets.length; i++) {
      int j = (previous + i)%targets.length;
      if (targets[j].isAlive) {
        DatanodeDescriptor primary = targets[primaryNodeIndex = j]; 
        primary.addBlockToBeRecovered(lastBlock, targets);
        NameNode.stateChangeLog.info("BLOCK* " + lastBlock
          + " recovery started, primary=" + primary);
        return;
      }
    }
  }
252676
def init_storage(self):
        """"""
        if not self.storage.exists('term'):
            self.storage.update({
                'term': 0,
            })

        self.storage.update({
            'voted_for': None
        })
605549
@Override
    public void setPeerRecoveryLeaseTimeout(int leaseTimeout)
    {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "setPeerRecoveryLeaseTimeout", leaseTimeout);

        // Store the Lease Timeout  
        _leaseTimeout = leaseTimeout;

        if (tc.isEntryEnabled())
            Tr.exit(tc, "setPeerRecoveryLeaseTimeout", this);

    }
727140
public void initAtStartup() {
        //final String appsToInit = ConfigurationManager.getConfigInstance().getString("evcache.appsToInit");
        final String appsToInit = EVCacheConfig.getInstance().getDynamicStringProperty("evcache.appsToInit", "").get();
        if (appsToInit != null && appsToInit.length() > 0) {
            final StringTokenizer apps = new StringTokenizer(appsToInit, ",");
            while (apps.hasMoreTokens()) {
                final String app = getAppName(apps.nextToken());
                if (log.isDebugEnabled()) log.debug("Initializing EVCache - " + app);
                initEVCache(app);
            }
        }
    }
823401
private void reinitializeIfNecessary() {
        if (this.resourceCache == null || this.resourceCache.size() > 0) {
            this.resourcesGraph = new ListenableDirectedGraph<>(DefaultEdge.class);
            this.neighborIndex = new DirectedNeighborIndex<>(this.resourcesGraph);
            this.resourcesGraph.addGraphListener(neighborIndex);
            this.resourceCache = new HashMap<>();
            this.resourcesGraph.addVertexSetListener(new VertexCacheListener());
        }
    }
1047106
def recovery(self, using=None, **kwargs):
        
        return self._get_connection(using).indices.recovery(index=self._name, **kwargs)
1042040
def with_source(self, lease):
        
        self.partition_id = lease.partition_id
        self.epoch = lease.epoch
        self.owner = lease.owner
        self.token = lease.token
        self.event_processor_context = lease.event_processor_context
321546
@Override
    public synchronized boolean claimPeerLeaseForRecovery(String recoveryIdentityToRecover, String myRecoveryIdentity, LeaseInfo leaseInfo) throws Exception
    {
        if (tc.isEntryEnabled())
            Tr.entry(tc, "claimPeerLeaseForRecovery", new java.lang.Object[] { recoveryIdentityToRecover, myRecoveryIdentity, leaseInfo, this });

        boolean peerClaimed = false;
        Connection conn = null;

        Statement lockingStmt = null;
        PreparedStatement updateStmt = null;
        ResultSet lockingRS = null;

        if (tc.isDebugEnabled())
            Tr.debug(tc, "Recovering server with recoveryIdentity - ", recoveryIdentityToRecover);

        try
        {
            // Have we acquired the reference to the DataSource yet?
            if (_theDS == null)
            {
                _theDS = getDataSourceFromProperties();
                // We've looked up the DS, so now we can get a JDBC connection
                if (_theDS != null)
                {
                    conn = getConnection(_theDS);
                }
            }
            else
            {
                // Try and get a new connection
                conn = _theDS.getConnection();
            }

            // If we were unable to get a connection, throw an exception
            if (conn == null)
            {
                if (tc.isEntryEnabled())
                    Tr.exit(tc, "claimPeerLeaseForRecovery", "Null connection InternalLogException");
                throw new InternalLogException("Failed to get JDBC Connection", null);
            }

            if (tc.isDebugEnabled())
                Tr.debug(tc, "Set autocommit FALSE on the connection");
            conn.setAutoCommit(false);

            // We can go ahead and access the Database
            lockingStmt = conn.createStatement();

            try
            {
                String queryString = "SELECT LEASE_TIME" +
                                     " FROM " + _leaseTableName +
                                     " WHERE SERVER_IDENTITY='" + recoveryIdentityToRecover + "' FOR UPDATE OF LEASE_TIME";
                if (tc.isDebugEnabled())
                    Tr.debug(tc, "Attempt to select the row for UPDATE using - " + queryString);
                lockingRS = lockingStmt.executeQuery(queryString);
            } catch (Exception e)
            {
                if (tc.isDebugEnabled())
                    Tr.debug(tc, "Query failed with exception: " + e);
                throw new InternalLogException("Failed to query the lease time, exc: " + e, null);
            } // eof Exception e block

            // see if we acquired the row
            if (lockingRS.next())
            {
                // We found the server row
                long storedLease = lockingRS.getLong(1);
                if (tc.isDebugEnabled())
                    Tr.debug(tc, "Acquired server row, stored lease value is: " + storedLease);

                // Has the lease expired?
                PeerLeaseData pld = new PeerLeaseData(recoveryIdentityToRecover, storedLease, _leaseTimeout);
                if (pld.isExpired())
                {
                    // Lease has expired, this means that this server is attempting peer recovery and 
                    // it has acquired the lock. If any other server is also trying to peer recover then
                    // they can fail. To make this happen, we'll update the lease time ourselves.

                    // Construct the UPDATE string
                    String updateString = "UPDATE " + _leaseTableName +
                                          " SET LEASE_TIME = ?, LEASE_OWNER = ?" +
                                          " WHERE SERVER_IDENTITY='" + recoveryIdentityToRecover + "'";
                    if (tc.isDebugEnabled())
                        Tr.debug(tc, "update lease for " + recoveryIdentityToRecover);

                    updateStmt = conn.prepareStatement(updateString);

                    // Set the Lease_time to the current time
                    //TODO:
                    long fir1 = System.currentTimeMillis();
                    updateStmt.setLong(1, fir1);
                    updateStmt.setString(2, myRecoveryIdentity);
                    if (tc.isDebugEnabled())
                        Tr.debug(tc, "Ready to UPDATE using string - " + updateString + " and time: " + fir1);

                    int ret = updateStmt.executeUpdate();

                    if (tc.isDebugEnabled())
                        Tr.debug(tc, "Have updated server row with return: " + ret);
                    peerClaimed = true;
                }
            }
            else
            {
                // We didn't find the row in the table
                if (tc.isDebugEnabled())
                    Tr.debug(tc, "Could not find row");
                throw new InternalLogException("Could not find lease", null);
            }

            if (tc.isDebugEnabled())
                Tr.debug(tc, "COMMIT the change");
            conn.commit();
        }
        // Catch and report an SQLException. 
        catch (SQLException sqlex)
        {
            if (tc.isDebugEnabled())
                Tr.debug(tc, "Lease update failed with exception: " + sqlex);
        } finally
        {
            if (lockingRS != null && !lockingRS.isClosed())
                lockingRS.close();
            if (lockingStmt != null && !lockingStmt.isClosed())
                lockingStmt.close();
            if (updateStmt != null && !updateStmt.isClosed())
                updateStmt.close();
            if (conn != null)
                conn.close();
        }

        if (tc.isEntryEnabled())
            Tr.exit(tc, "claimPeerLeaseForRecovery");
        return peerClaimed;
    }
988069
public void initEvictor() {
        MapEvictionPolicy mapEvictionPolicy = getMapEvictionPolicy();
        if (mapEvictionPolicy == null) {
            evictor = NULL_EVICTOR;
        } else {
            MemoryInfoAccessor memoryInfoAccessor = getMemoryInfoAccessor();
            EvictionChecker evictionChecker = new EvictionChecker(memoryInfoAccessor, mapServiceContext);
            NodeEngine nodeEngine = mapServiceContext.getNodeEngine();
            IPartitionService partitionService = nodeEngine.getPartitionService();
            int batchSize = nodeEngine.getProperties().getInteger(MAP_EVICTION_BATCH_SIZE);
            evictor = new EvictorImpl(mapEvictionPolicy, evictionChecker, partitionService, batchSize);
        }
    }
829631
public void performRecovery(ObjectManagerState objectManagerState)
                    throws ObjectManagerException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass,
                        "performRecovery",
                        "objectManagerState=" + objectManagerState + "(ObjectManagerState)");

        if (Tracing.isAnyTracingEnabled() && trace.isDebugEnabled())
            trace.debug(this, cclass,
                        "logicalUnitOfWork=" + logicalUnitOfWork + "(LogicalUnitOfWork)"
                                        + " transactionState=" + transactionState + "(int)"
                                        + " token=" + token + "(token)"
                                        + " managedObjectBytes.length=" + managedObjectBytes.length + "(int)");

        // Recover the ManagedObject from its serialized bytes.
        ManagedObject addedManagedObject = ManagedObject.restoreFromSerializedBytes(managedObjectBytes,
                                                                                    objectManagerState);

        // Redo the add of the ManagedObject using its original Transaction.
        Transaction transactionForRecovery = objectManagerState.getTransaction(logicalUnitOfWork);
        // Reestablish the restored ManagedObject.
        ManagedObject managedObject = token.setManagedObject(addedManagedObject);
        managedObject.state = ManagedObject.stateConstructed;

        transactionForRecovery.add(managedObject); // Redo the add.
        // No need to reset the transaction state because Add can only be executed before
        // the transaction is prepared.
        // transactionForRecovery.internalTransaction.resetState(transactionState);

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass,
                       "performRecovery");
    }
781755
private void initializeDefaultTenant() {
        DBService dbService = DBService.instance();
        dbService.createNamespace();
        dbService.createStoreIfAbsent(SchemaService.APPS_STORE_NAME, false);
        dbService.createStoreIfAbsent(TaskManagerService.TASKS_STORE_NAME, false);
        dbService.createStoreIfAbsent(TENANTS_STORE_NAME, false);
        storeInitialDefaultTenantDef();
    }
427851
public void addRecoverCommand() {
        StringBuilder buf = new StringBuilder();
        buf.append("(recover)");
        fifo.add(fifo.size(), buf.toString());
    }
381622
def init_app(self, app):
        """"""
        self.init_config(app)
        app.extensions['invenio-records-rest'] = _RecordRESTState(app)
203800
public void init(QueryHandlerEntry queryHandlerEntry) throws IOException, RepositoryConfigurationException
   {
      for (SimpleParameterEntry parameter : queryHandlerEntry.getParameters())
      {
         setParam(parameter.getName(), parameter.getValue());
      }
      /*rsync is used as local index recovery strategy*/
      if(SearchIndex.INDEX_RECOVERY_RSYNC_STRATEGY.equals(searchIndex.getIndexRecoveryStrategy()) ||
              SearchIndex.INDEX_RECOVERY_RSYNC_WITH_DELETE_STRATEGY.equals(searchIndex.getIndexRecoveryStrategy()))
      {
         searchIndex.setRsyncConfiguration(new RSyncConfiguration(queryHandlerEntry));
      }
   }
1093805
def init(*args, **kwargs):
    
    global _initial_client
    client = Client(*args, **kwargs)
    Hub.current.bind_client(client)
    rv = _InitGuard(client)
    if client is not None:
        _initial_client = weakref.ref(client)
    return rv
605526
def initialize(self, init_value, context=None, force=False):
        

        if not force and self._instance is not None:
            raise ConfigurationAlreadyInitializedError(
                'Configuration manager object is already initialized.'
            )

        self.__class__._instance = Root(init_value, context=context)
469251
public final void intialize() throws IllegalStateException {
        synchronized (this) {
            if (tracker != null) {
                throw new IllegalStateException(
                    "DelegatingClassResolver [" + this + "] had been initialized.");
            }
            tracker = new ClassResolverTracker(context, applicationName);
            tracker.open();
        }
    }