Search in sources :

Example 1 with IStatefulStorage

use of org.apache.heron.spi.statefulstorage.IStatefulStorage in project heron by twitter.

the class CheckpointManager method init.

public void init(String topologyName, String topologyId, String checkpointMgrId, String serverHost, int serverPort, SystemConfig systemConfig, CheckpointManagerConfig checkpointManagerConfig) throws IOException, CheckpointManagerException {
    LOG.info("Initializing CheckpointManager");
    checkpointManagerServerLoop = new NIOLooper();
    HeronSocketOptions serverSocketOptions = new HeronSocketOptions(checkpointManagerConfig.getWriteBatchSize(), checkpointManagerConfig.getWriteBatchTime(), checkpointManagerConfig.getReadBatchSize(), checkpointManagerConfig.getReadBatchTime(), checkpointManagerConfig.getSocketSendSize(), checkpointManagerConfig.getSocketReceiveSize(), checkpointManagerConfig.getMaximumPacketSize());
    // Setup the IStatefulStorage
    IStatefulStorage statefulStorage = setupStatefulStorage(topologyName, checkpointManagerConfig);
    // Start the server
    this.checkpointManagerServer = new CheckpointManagerServer(topologyName, topologyId, checkpointMgrId, statefulStorage, checkpointManagerServerLoop, serverHost, serverPort, serverSocketOptions);
}
Also used : NIOLooper(org.apache.heron.common.basics.NIOLooper) HeronSocketOptions(org.apache.heron.common.network.HeronSocketOptions) IStatefulStorage(org.apache.heron.spi.statefulstorage.IStatefulStorage)

Example 2 with IStatefulStorage

use of org.apache.heron.spi.statefulstorage.IStatefulStorage in project heron by twitter.

the class CheckpointManager method setupStatefulStorage.

private static IStatefulStorage setupStatefulStorage(String topologyName, CheckpointManagerConfig checkpointManagerConfig) throws CheckpointManagerException {
    IStatefulStorage statefulStorage;
    String classname = checkpointManagerConfig.getStorageClassname();
    try {
        statefulStorage = (IStatefulStorage) Class.forName(classname).newInstance();
    } catch (InstantiationException e) {
        throw new CheckpointManagerException(classname + " class must have a no-arg constructor.", e);
    } catch (IllegalAccessException e) {
        throw new CheckpointManagerException(classname + " class must be concrete.", e);
    } catch (ClassNotFoundException e) {
        throw new CheckpointManagerException(classname + " class must be a class path.", e);
    }
    try {
        statefulStorage.init(topologyName, Collections.unmodifiableMap(checkpointManagerConfig.getStatefulStorageConfig()));
    } catch (StatefulStorageException e) {
        throw new CheckpointManagerException(classname + " init threw exception", e);
    }
    return statefulStorage;
}
Also used : StatefulStorageException(org.apache.heron.spi.statefulstorage.StatefulStorageException) IStatefulStorage(org.apache.heron.spi.statefulstorage.IStatefulStorage)

Aggregations

IStatefulStorage (org.apache.heron.spi.statefulstorage.IStatefulStorage)2 NIOLooper (org.apache.heron.common.basics.NIOLooper)1 HeronSocketOptions (org.apache.heron.common.network.HeronSocketOptions)1 StatefulStorageException (org.apache.heron.spi.statefulstorage.StatefulStorageException)1