Search in sources :

Example 6 with StorageAgent

use of com.datatorrent.api.StorageAgent in project apex-core by apache.

the class PhysicalPlan method syncCheckpoints.

/**
   * Read available checkpoints from storage agent for all operators.
   * @param startTime
   * @param currentTime
   * @throws IOException
   */
public void syncCheckpoints(long startTime, long currentTime) throws IOException {
    for (PTOperator oper : getAllOperators().values()) {
        StorageAgent sa = oper.operatorMeta.getValue(OperatorContext.STORAGE_AGENT);
        long[] windowIds = sa.getWindowIds(oper.getId());
        Arrays.sort(windowIds);
        oper.checkpoints.clear();
        for (long wid : windowIds) {
            if (wid != Stateless.WINDOW_ID) {
                oper.addCheckpoint(wid, startTime);
            }
        }
    }
}
Also used : AsyncStorageAgent(org.apache.apex.common.util.AsyncStorageAgent) StorageAgent(com.datatorrent.api.StorageAgent)

Example 7 with StorageAgent

use of com.datatorrent.api.StorageAgent in project apex-core by apache.

the class PhysicalPlan method initCheckpoint.

private void initCheckpoint(PTOperator oper, Operator oo, Checkpoint checkpoint) {
    try {
        LOG.debug("Writing activation checkpoint {} {} {}", checkpoint, oper, oo);
        long windowId = oper.isOperatorStateLess() ? Stateless.WINDOW_ID : checkpoint.windowId;
        StorageAgent agent = oper.operatorMeta.getValue(OperatorContext.STORAGE_AGENT);
        agent.save(oo, oper.id, windowId);
        if (agent instanceof AsyncStorageAgent) {
            ((AsyncStorageAgent) agent).flush(oper.id, windowId);
        }
    } catch (IOException e) {
        // inconsistent state, no recovery option, requires shutdown
        throw new IllegalStateException("Failed to write operator state after partition change " + oper, e);
    }
    oper.setRecoveryCheckpoint(checkpoint);
    if (!Checkpoint.INITIAL_CHECKPOINT.equals(checkpoint)) {
        oper.checkpoints.add(checkpoint);
    }
}
Also used : AsyncStorageAgent(org.apache.apex.common.util.AsyncStorageAgent) AsyncStorageAgent(org.apache.apex.common.util.AsyncStorageAgent) StorageAgent(com.datatorrent.api.StorageAgent) IOException(java.io.IOException)

Aggregations

StorageAgent (com.datatorrent.api.StorageAgent)7 IOException (java.io.IOException)3 AsyncStorageAgent (org.apache.apex.common.util.AsyncStorageAgent)3 AsyncFSStorageAgent (com.datatorrent.common.util.AsyncFSStorageAgent)2 Checkpoint (com.datatorrent.stram.api.Checkpoint)2 OperatorDeployInfo (com.datatorrent.stram.api.OperatorDeployInfo)2 UnifierDeployInfo (com.datatorrent.stram.api.OperatorDeployInfo.UnifierDeployInfo)2 Context (com.datatorrent.api.Context)1 InputOperator (com.datatorrent.api.InputOperator)1 Operator (com.datatorrent.api.Operator)1 ProcessingMode (com.datatorrent.api.Operator.ProcessingMode)1 Stats (com.datatorrent.api.Stats)1 BasicContainerOptConfigurator (com.datatorrent.common.util.BasicContainerOptConfigurator)1 FSStorageAgent (com.datatorrent.common.util.FSStorageAgent)1 ContainerContext (com.datatorrent.stram.api.ContainerContext)1 ContainerStats (com.datatorrent.stram.api.StreamingContainerUmbilicalProtocol.ContainerStats)1 StreamingContainerContext (com.datatorrent.stram.api.StreamingContainerUmbilicalProtocol.StreamingContainerContext)1 ClientRMHelper (com.datatorrent.stram.client.StramClientUtils.ClientRMHelper)1 PTOperator (com.datatorrent.stram.plan.physical.PTOperator)1 ByteBuffer (java.nio.ByteBuffer)1