private void handleDiscontinueFeedTypeMessage(EndFeedMessage endFeedMessage) throws Exception { FeedId sourceFeedId = endFeedMessage.getSourceFeedId(); SubscribableFeedRuntimeId subscribableRuntimeId = new SubscribableFeedRuntimeId(sourceFeedId, FeedRuntimeType.INTAKE, partition); ISubscribableRuntime feedRuntime = feedManager.getFeedSubscriptionManager().getSubscribableRuntime(subscribableRuntimeId); IAdapterRuntimeManager adapterRuntimeManager = ((IngestionRuntime) feedRuntime).getAdapterRuntimeManager(); adapterRuntimeManager.stop(); if (LOGGER.isLoggable(Level.INFO)) { LOGGER.info("Stopped Adapter " + adapterRuntimeManager); } }
private void handleFeedTupleCommitResponseMessage( FeedTupleCommitResponseMessage commitResponseMessage) { FeedConnectionId connectionId = commitResponseMessage.getConnectionId(); FeedRuntimeManager runtimeManager = feedManager.getFeedConnectionManager().getFeedRuntimeManager(connectionId); Set<FeedRuntimeId> runtimes = runtimeManager.getFeedRuntimes(); for (FeedRuntimeId runtimeId : runtimes) { FeedRuntime runtime = runtimeManager.getFeedRuntime(runtimeId); switch (runtimeId.getFeedRuntimeType()) { case COLLECT: FeedCollectRuntimeInputHandler inputHandler = (FeedCollectRuntimeInputHandler) runtime.getInputHandler(); int maxBasePersisted = commitResponseMessage.getMaxWindowAcked(); inputHandler.dropTill(IntakePartitionStatistics.ACK_WINDOW_SIZE * (maxBasePersisted + 1)); break; case STORE: MonitoredBufferStorageTimerTask sTask = runtime.getInputHandler().getmBuffer().getStorageTimeTrackingRateTask(); sTask.receiveCommitAckResponse(commitResponseMessage); break; } } commitResponseMessage.getIntakePartition(); SubscribableFeedRuntimeId sid = new SubscribableFeedRuntimeId(connectionId.getFeedId(), FeedRuntimeType.INTAKE, partition); IngestionRuntime ingestionRuntime = (IngestionRuntime) feedManager.getFeedSubscriptionManager().getSubscribableRuntime(sid); if (ingestionRuntime != null) { IIntakeProgressTracker tracker = ingestionRuntime.getAdapterRuntimeManager().getProgressTracker(); if (tracker != null) { tracker.notifyIngestedTupleTimestamp(System.currentTimeMillis()); } } }
private void handleThrottlingEnabledMessage(ThrottlingEnabledFeedMessage throttlingMessage) { FeedConnectionId connectionId = throttlingMessage.getConnectionId(); FeedRuntimeManager runtimeManager = feedManager.getFeedConnectionManager().getFeedRuntimeManager(connectionId); Set<FeedRuntimeId> runtimes = runtimeManager.getFeedRuntimes(); for (FeedRuntimeId runtimeId : runtimes) { if (runtimeId.getFeedRuntimeType().equals(FeedRuntimeType.STORE)) { FeedRuntime storeRuntime = runtimeManager.getFeedRuntime(runtimeId); ((StorageSideMonitoredBuffer) (storeRuntime.getInputHandler().getmBuffer())) .setAcking(false); if (LOGGER.isLoggable(Level.INFO)) { LOGGER.info( "Acking Disabled in view of throttling that has been activted upfron in the pipeline " + connectionId); } } } }
private void handlePrepareStallMessage(PrepareStallMessage prepareStallMessage) throws HyracksDataException { FeedConnectionId connectionId = prepareStallMessage.getConnectionId(); int computePartitionsRetainLimit = prepareStallMessage.getComputePartitionsRetainLimit(); FeedRuntimeManager runtimeManager = feedManager.getFeedConnectionManager().getFeedRuntimeManager(connectionId); Set<FeedRuntimeId> feedRuntimes = runtimeManager.getFeedRuntimes(); for (FeedRuntimeId runtimeId : feedRuntimes) { FeedRuntime runtime = runtimeManager.getFeedRuntime(runtimeId); switch (runtimeId.getFeedRuntimeType()) { case COMPUTE: Mode requiredMode = runtimeId.getPartition() <= computePartitionsRetainLimit ? Mode.STALL : Mode.END; runtime.setMode(requiredMode); break; default: runtime.setMode(Mode.STALL); break; } } }
private void handleTerminateFlowMessage(FeedConnectionId connectionId) throws HyracksDataException { FeedRuntimeManager runtimeManager = feedManager.getFeedConnectionManager().getFeedRuntimeManager(connectionId); Set<FeedRuntimeId> feedRuntimes = runtimeManager.getFeedRuntimes(); boolean found = false; for (FeedRuntimeId runtimeId : feedRuntimes) { FeedRuntime runtime = runtimeManager.getFeedRuntime(runtimeId); if (runtime.getRuntimeId().getRuntimeType().equals(FeedRuntimeType.COLLECT)) { ((CollectionRuntime) runtime).getFrameCollector().setState(State.HANDOVER); found = true; if (LOGGER.isLoggable(Level.INFO)) { LOGGER.info("Switched " + runtime + " to Hand Over stage"); } } } if (!found) { throw new HyracksDataException("COLLECT Runtime not found!"); } }
private void hanldeDisconnectFeedTypeMessage(EndFeedMessage endFeedMessage) throws Exception { if (LOGGER.isLoggable(Level.INFO)) { LOGGER.info("Ending feed:" + endFeedMessage.getFeedConnectionId()); } FeedRuntimeId runtimeId = null; FeedRuntimeType subscribableRuntimeType = ((EndFeedMessage) message).getSourceRuntimeType(); if (endFeedMessage.isCompleteDisconnection()) { // subscribableRuntimeType represents the location at which the feed connection receives data FeedRuntimeType runtimeType = null; switch (subscribableRuntimeType) { case INTAKE: runtimeType = FeedRuntimeType.COLLECT; break; case COMPUTE: runtimeType = FeedRuntimeType.COMPUTE_COLLECT; break; default: throw new IllegalStateException( "Invalid subscribable runtime type " + subscribableRuntimeType); } runtimeId = new FeedRuntimeId(runtimeType, partition, FeedRuntimeId.DEFAULT_OPERAND_ID); CollectionRuntime feedRuntime = (CollectionRuntime) feedManager.getFeedConnectionManager().getFeedRuntime(connectionId, runtimeId); feedRuntime.getSourceRuntime().unsubscribeFeed(feedRuntime); if (LOGGER.isLoggable(Level.INFO)) { LOGGER.info("Complete Unsubscription of " + endFeedMessage.getFeedConnectionId()); } } else { // subscribaleRuntimeType represents the location for data hand-off in presence of subscribers switch (subscribableRuntimeType) { case INTAKE: // illegal state as data hand-off from one feed to another does not happen at intake throw new IllegalStateException( "Illegal State, invalid runtime type " + subscribableRuntimeType); case COMPUTE: // feed could be primary or secondary, doesn't matter SubscribableFeedRuntimeId feedSubscribableRuntimeId = new SubscribableFeedRuntimeId( connectionId.getFeedId(), FeedRuntimeType.COMPUTE, partition); ISubscribableRuntime feedRuntime = feedManager .getFeedSubscriptionManager() .getSubscribableRuntime(feedSubscribableRuntimeId); DistributeFeedFrameWriter dWriter = (DistributeFeedFrameWriter) feedRuntime.getFeedFrameWriter(); Map<IFrameWriter, FeedFrameCollector> registeredCollectors = dWriter.getRegisteredReaders(); IFrameWriter unsubscribingWriter = null; for (Entry<IFrameWriter, FeedFrameCollector> entry : registeredCollectors.entrySet()) { IFrameWriter frameWriter = entry.getKey(); FeedRuntimeInputHandler feedFrameWriter = (FeedRuntimeInputHandler) frameWriter; if (feedFrameWriter.getConnectionId().equals(endFeedMessage.getFeedConnectionId())) { unsubscribingWriter = feedFrameWriter; dWriter.unsubscribeFeed(unsubscribingWriter); if (LOGGER.isLoggable(Level.INFO)) { LOGGER.info("Partial Unsubscription of " + unsubscribingWriter); } break; } } break; } } if (LOGGER.isLoggable(Level.INFO)) { LOGGER.info("Unsubscribed from feed :" + connectionId); } }