@Transition(from = "ERROR", to = "OFFLINE") public void onBecomeOfflineFromError(Message message, NotificationContext context) { LOGGER.info("Resetting the state for broker resource:{} from ERROR to OFFLINE", message.getPartitionName()); } }
@Transition(from = "ERROR", to = "OFFLINE") public void onBecomeOfflineFromError(Message message, NotificationContext context) { _logger.info("Resetting the state for segment:{} from ERROR to OFFLINE", message.getPartitionName()); } }
@Transition(from = "OFFLINE", to = "CONSUMING") public void onBecomeConsumingFromOffline(Message message, NotificationContext context) { Preconditions.checkState(SegmentName.isLowLevelConsumerSegmentName(message.getPartitionName()), "Tried to go into CONSUMING state on non-low level segment"); _logger.info("SegmentOnlineOfflineStateModel.onBecomeConsumingFromOffline() : " + message); // We do the same processing as usual for going to the consuming state, which adds the segment to the table data // manager and starts Kafka consumption onBecomeOnlineFromOffline(message, context); }
@Transition(from = "ONLINE", to = "DROPPED") public void onBecomeDroppedFromOnline(Message message, NotificationContext context) { try { LOGGER.info("BrokerResourceOnlineOfflineStateModel.onBecomeDroppedFromOnline() : " + message); String tableName = message.getPartitionName(); _helixExternalViewBasedRouting.markDataResourceOffline(tableName); _tableQueryQuotaManager.dropTableQueryQuota(tableName); } catch (Exception e) { LOGGER.error("Caught exception during ONLINE -> DROPPED transition", e); Utils.rethrowException(e); throw new AssertionError("Should not reach this"); } }
@Transition(from = "ONLINE", to = "OFFLINE") public void onBecomeOfflineFromOnline(Message message, NotificationContext context) { try { LOGGER.info("BrokerResourceOnlineOfflineStateModel.onBecomeOfflineFromOnline() : " + message); String tableName = message.getPartitionName(); _helixExternalViewBasedRouting.markDataResourceOffline(tableName); _tableQueryQuotaManager.dropTableQueryQuota(tableName); } catch (Exception e) { LOGGER.error("Caught exception during ONLINE -> OFFLINE transition", e); Utils.rethrowException(e); throw new AssertionError("Should not reach this"); } }
@Transition(from = "OFFLINE", to = "DROPPED") public void onBecomeDroppedFromOffline(Message message, NotificationContext context) { try { LOGGER.info("BrokerResourceOnlineOfflineStateModel.onBecomeDroppedFromOffline() : " + message); String tableName = message.getPartitionName(); _helixExternalViewBasedRouting.markDataResourceOffline(tableName); _tableQueryQuotaManager.dropTableQueryQuota(tableName); } catch (Exception e) { LOGGER.error("Caught exception during OFFLINE -> DROPPED transition", e); Utils.rethrowException(e); throw new AssertionError("Should not reach this"); } }
@Override public MessageHandler createHandler(Message message, NotificationContext context) { String msgSubType = message.getMsgSubType(); switch (msgSubType) { case TimeboundaryRefreshMessage.REFRESH_TIME_BOUNDARY_MSG_SUB_TYPE: LOGGER.info("time refresh msg received {} for table {}", message.getPartitionName()); return new TimeboundaryRefreshMessageHandler(new TimeboundaryRefreshMessage(message), context); default: throw new UnsupportedOperationException("Unsupported user defined message sub type: " + msgSubType); } }
@Transition(from = "OFFLINE", to = "DROPPED") public void onBecomeDroppedFromOffline(Message message, NotificationContext context) { _logger.info("SegmentOnlineOfflineStateModel.onBecomeDroppedFromOffline() : " + message); String tableNameWithType = message.getResourceName(); String segmentName = message.getPartitionName(); // This method might modify the file on disk. Use segment lock to prevent race condition Lock segmentLock = SegmentLocks.getSegmentLock(tableNameWithType, segmentName); try { segmentLock.lock(); final File segmentDir = new File(_fetcherAndLoader.getSegmentLocalDirectory(tableNameWithType, segmentName)); if (segmentDir.exists()) { FileUtils.deleteQuietly(segmentDir); _logger.info("Deleted segment directory {}", segmentDir); } } catch (final Exception e) { _logger.error("Cannot delete the segment : " + segmentName + " from local directory!\n" + e.getMessage(), e); Utils.rethrowException(e); } finally { segmentLock.unlock(); } }
@Transition(from = "ONLINE", to = "OFFLINE") public void onBecomeOfflineFromOnline(Message message, NotificationContext context) { _logger.info("SegmentOnlineOfflineStateModel.onBecomeOfflineFromOnline() : " + message); String tableNameWithType = message.getResourceName(); String segmentName = message.getPartitionName(); try { _instanceDataManager.removeSegment(tableNameWithType, segmentName); } catch (Exception e) { _logger.error("Caught exception in state transition from ONLINE -> OFFLINE for resource: {}, partition: {}", tableNameWithType, segmentName, e); Utils.rethrowException(e); } }
@Transition(from = "CONSUMING", to = "OFFLINE") public void onBecomeOfflineFromConsuming(Message message, NotificationContext context) { _logger.info("SegmentOnlineOfflineStateModel.onBecomeOfflineFromConsuming() : " + message); String realtimeTableName = message.getResourceName(); String segmentName = message.getPartitionName(); try { _instanceDataManager.removeSegment(realtimeTableName, segmentName); } catch (Exception e) { _logger.error("Caught exception in state transition from CONSUMING -> OFFLINE for resource: {}, partition: {}", realtimeTableName, segmentName, e); Utils.rethrowException(e); } }
@Transition(from = "OFFLINE", to = "CONSUMING") public void onBecomeConsumingFromOffline(Message message, NotificationContext context) { _currentSegment = message.getPartitionName(); }
@Transition(from = "OFFLINE", to = "ONLINE") public void onBecomeOnlineFromOffline(Message message, NotificationContext context) { _logger.info("SegmentOnlineOfflineStateModel.onBecomeOnlineFromOffline() : " + message); String tableNameWithType = message.getResourceName(); String segmentName = message.getPartitionName(); try { TableType tableType = TableNameBuilder.getTableTypeFromTableName(message.getResourceName()); Preconditions.checkNotNull(tableType); if (tableType == TableType.OFFLINE) { _fetcherAndLoader.addOrReplaceOfflineSegment(tableNameWithType, segmentName); } else { _instanceDataManager.addRealtimeSegment(tableNameWithType, segmentName); } } catch (Exception e) { _logger.error("Caught exception in state transition from OFFLINE -> ONLINE for resource: {}, partition: {}", tableNameWithType, segmentName, e); Utils.rethrowException(e); } }
@Transition(from = "CONSUMING", to = "ONLINE") public void onBecomeOnlineFromConsuming(Message message, NotificationContext context) { String realtimeTableName = message.getResourceName(); String segmentNameStr = message.getPartitionName(); LLCSegmentName segmentName = new LLCSegmentName(segmentNameStr);
@Transition(from = "OFFLINE", to = "ONLINE") public void onBecomeOnlineFromOffline(Message message, NotificationContext context) { try { LOGGER.info("BrokerResourceOnlineOfflineStateModel.onBecomeOnlineFromOffline() : " + message); Builder keyBuilder = _helixManager.getHelixDataAccessor().keyBuilder(); String tableName = message.getPartitionName(); HelixDataAccessor helixDataAccessor = _helixManager.getHelixDataAccessor(); List<InstanceConfig> instanceConfigList = helixDataAccessor.getChildValues(keyBuilder.instanceConfigs()); TableConfig tableConfig = ZKMetadataProvider.getTableConfig(_propertyStore, tableName); _helixExternalViewBasedRouting.markDataResourceOnline(tableConfig, HelixHelper.getExternalViewForResource(_helixAdmin, _helixManager.getClusterName(), tableName), instanceConfigList); _tableQueryQuotaManager.initTableQueryQuota(tableConfig, HelixHelper .getExternalViewForResource(_helixAdmin, _helixManager.getClusterName(), BROKER_RESOURCE_INSTANCE)); } catch (Exception e) { LOGGER.error("Caught exception during OFFLINE -> ONLINE transition", e); Utils.rethrowException(e); throw new AssertionError("Should not reach this"); } }
public void onBecomeDroppedFromOffline(Message message, NotificationContext context) { System.out.println("TestOnlineOfflineStateModel.onBecomeDroppedFromOffline() for topic: " + message.getResourceName() + ", partition: " + message.getPartitionName() + " to instance: " + _instanceId); sleep(); }
public void onBecomeOnlineFromOffline(Message message, NotificationContext context) { System.out.println("TestOnlineOfflineStateModel.onBecomeOnlineFromOffline for topic: " + message.getResourceName() + ", partition: " + message.getPartitionName() + " to instance: " + _instanceId); sleep(); }
public void onBecomeOfflineFromOnline(Message message, NotificationContext context) { System.out.println("TestOnlineOfflineStateModel.onBecomeOfflineFromOnline for topic: " + message.getResourceName() + ", partition: " + message.getPartitionName() + " to instance: " + _instanceId); sleep(); }
@Transition(from = "ONLINE", to = "OFFLINE") public void onBecomeOfflineFromOnline(Message message, NotificationContext context) { LOGGER.info("ControllerStateModel.onBecomeOfflineFromOnline() for resource: " + message.getResourceName() + ", partition: " + message.getPartitionName()); handleStateChange(message); }
@Transition(from = "ERROR", to = "DROPPED") public void onBecomeDroppedFromError(Message message, NotificationContext context) { LOGGER.info("ControllerStateModel.onBecomeDroppedFromError() for resource: " + message.getResourceName() + ", partition: " + message.getPartitionName()); handleStateChange(message); }
@Transition(from = "OFFLINE", to = "DROPPED") public void onBecomeDroppedFromOffline(Message message, NotificationContext context) { LOGGER.info("ControllerStateModel.onBecomeDroppedFromOffline() for resource: " + message.getResourceName() + ", partition: " + message.getPartitionName()); handleStateChange(message); }