@Override public ReplicationProperties newReplicationProperties() { return new ReplicationProperties(propertiesAccessor); }
@Override public boolean isReplicationEnabled() { return replicationProperties.isReplicationEnabled(); }
public LogReplicationManager(INcApplicationContext appCtx, IReplicationManager replicationManager) { this.appCtx = appCtx; this.replicationManager = replicationManager; final ReplicationProperties replicationProperties = appCtx.getReplicationProperties(); logPageSize = replicationProperties.getLogBufferPageSize(); logBatchSize = replicationProperties.getLogBatchSize(); executor = appCtx.getThreadExecutor(); emptyLogBuffersQ = new LinkedBlockingQueue<>(); pendingFlushLogBuffersQ = new LinkedBlockingQueue<>(); initBuffers(replicationProperties.getLogBufferNumOfPages()); TxnLogReplicator txnlogReplicator = new TxnLogReplicator(emptyLogBuffersQ, pendingFlushLogBuffersQ); ((ExecutorService) executor).submit(txnlogReplicator); }
ILibraryManager libraryManager = new ExternalLibraryManager(); ReplicationProperties repProp = new ReplicationProperties(PropertiesAccessor.getInstance(ccServiceCtx.getAppConfig())); INcLifecycleCoordinator lifecycleCoordinator = createNcLifeCycleCoordinator(repProp.isReplicationEnabled()); ExternalLibraryUtils.setUpExternaLibraries(libraryManager, false); componentProvider = new StorageComponentProvider();
@Override public void run() { final String nodeId = appCtx.getServiceContext().getNodeId(); Thread.currentThread().setName(nodeId + " Replication Channel Thread"); final ReplicationProperties replicationProperties = appCtx.getReplicationProperties(); final String nodeIP = replicationProperties.getReplicationAddress(); final int dataPort = replicationProperties.getReplicationPort(); try { serverSocketChannel = ServerSocketChannel.open(); serverSocketChannel.configureBlocking(true); InetSocketAddress replicationChannelAddress = new InetSocketAddress(InetAddress.getByName(nodeIP), dataPort); serverSocketChannel.socket().bind(replicationChannelAddress); LOGGER.log(Level.INFO, "opened Replication Channel @ IP Address: " + nodeIP + ":" + dataPort); while (serverSocketChannel.isOpen()) { SocketChannel socketChannel = serverSocketChannel.accept(); connectionAccepted(socketChannel); } } catch (AsynchronousCloseException e) { LOGGER.debug("Replication channel closed", e); } catch (IOException e) { throw new IllegalStateException("Failed to bind replication channel @ " + nodeIP + ":" + dataPort, e); } }
public ReplicationManager(INcApplicationContext appCtx, ReplicationProperties replicationProperties) { this.replicationProperties = replicationProperties; this.appCtx = appCtx; strategy = ReplicationStrategyFactory.create(replicationProperties.getReplicationStrategy()); logReplicationManager = new LogReplicationManager(appCtx, this); lsnIndexReplicationManager = new IndexReplicationManager(appCtx, this); }
private void ensureComponentLsnFlushed(INcApplicationContext appCtx) throws HyracksDataException, InterruptedException { final ResourceReference indexRef = ResourceReference.of(file); final IIndexCheckpointManagerProvider checkpointManagerProvider = appCtx.getIndexCheckpointManagerProvider(); final IIndexCheckpointManager indexCheckpointManager = checkpointManagerProvider.get(indexRef); long replicationTimeOut = TimeUnit.SECONDS.toMillis(appCtx.getReplicationProperties().getReplicationTimeOut()); synchronized (indexCheckpointManager) { // wait until the lsn mapping is flushed to disk while (!indexCheckpointManager.isFlushed(masterLsn)) { if (replicationTimeOut <= 0) { throw new ReplicationException(new TimeoutException("Couldn't receive flush lsn from master")); } final long startTime = System.nanoTime(); indexCheckpointManager.wait(replicationTimeOut); replicationTimeOut -= TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startTime); } final long componentSequence = IndexComponentFileReference.of(indexRef.getName()).getSequenceEnd(); indexCheckpointManager.replicated(componentSequence, masterLsn, lastComponentId); } }
activeProperties = new ActiveProperties(propertiesAccessor); extensionProperties = new ExtensionProperties(propertiesAccessor); replicationProperties = new ReplicationProperties(propertiesAccessor); this.ftStrategy = ftStrategy; this.buildProperties = new BuildProperties(propertiesAccessor);
public RecoveryManager(INCServiceContext serviceCtx, ITransactionSubsystem txnSubsystem) { this.serviceCtx = serviceCtx; this.txnSubsystem = txnSubsystem; this.appCtx = txnSubsystem.getApplicationContext(); logMgr = (LogManager) txnSubsystem.getLogManager(); ReplicationProperties repProperties = appCtx.getReplicationProperties(); replicationEnabled = repProperties.isReplicationEnabled(); localResourceRepository = (PersistentLocalResourceRepository) appCtx.getLocalResourceRepository(); cachedEntityCommitsPerJobSize = txnSubsystem.getTransactionProperties().getJobRecoveryMemorySize(); checkpointManager = txnSubsystem.getCheckpointManager(); }
public TransactionSubsystem(INcApplicationContext appCtx, IRecoveryManagerFactory recoveryManagerFactory) { this.appCtx = appCtx; this.id = appCtx.getServiceContext().getNodeId(); this.txnProperties = appCtx.getTransactionProperties(); this.transactionManager = new TransactionManager(this); this.lockManager = new ConcurrentLockManager(txnProperties.getLockManagerShrinkTimer()); final ReplicationProperties repProperties = appCtx.getReplicationProperties(); final boolean replicationEnabled = repProperties.isReplicationEnabled(); final CheckpointProperties checkpointProperties = new CheckpointProperties(txnProperties, id); if (LOGGER.isInfoEnabled()) { LOGGER.log(Level.INFO, "Checkpoint Properties: " + checkpointProperties); } checkpointManager = CheckpointManagerFactory.create(this, checkpointProperties); final Checkpoint latestCheckpoint = checkpointManager.getLatest(); if (latestCheckpoint != null) { transactionManager.ensureMaxTxnId(latestCheckpoint.getMaxTxnId()); } this.logManager = replicationEnabled ? new LogManagerWithReplication(this) : new LogManager(this); this.recoveryManager = recoveryManagerFactory.createRecoveryManager(appCtx.getServiceContext(), this); if (txnProperties.isCommitProfilerEnabled()) { ecp = new EntityCommitProfiler(this, this.txnProperties.getCommitProfilerReportInterval()); ((ExecutorService) appCtx.getThreadExecutor()).submit(ecp); } }
this.ncServiceContext); if (replicationProperties.isReplicationEnabled()) { replicationManager = new ReplicationManager(this, replicationProperties);