本文整理汇总了Java中org.apache.helix.model.Message.getResourceName方法的典型用法代码示例。如果您正苦于以下问题:Java Message.getResourceName方法的具体用法?Java Message.getResourceName怎么用?Java Message.getResourceName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.helix.model.Message
的用法示例。
在下文中一共展示了Message.getResourceName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findExecutorServiceForMsg
import org.apache.helix.model.Message; //导入方法依赖的package包/类
/**
* Find the executor service for the message. A message can have a per-statemodelfactory
* executor service, or per-message type executor service.
*/
ExecutorService findExecutorServiceForMsg(Message message) {
ExecutorService executorService = _executorMap.get(message.getMsgType());
if (message.getMsgType().equals(MessageType.STATE_TRANSITION.name())) {
if(message.getBatchMessageMode() == true) {
executorService = _batchMessageExecutorService;
} else {
String resourceName = message.getResourceName();
if (resourceName != null) {
String key = getPerResourceStateTransitionPoolName(resourceName);
String perStateTransitionTypeKey =
getStateTransitionType(key, message.getFromState(), message.getToState());
if (perStateTransitionTypeKey != null && _executorMap.containsKey(perStateTransitionTypeKey)) {
LOG.info(String.format("Find per state transition type thread pool for resource %s from %s to %s",
message.getResourceName(), message.getFromState(), message.getToState()));
executorService = _executorMap.get(perStateTransitionTypeKey);
} else if (_executorMap.containsKey(key)) {
LOG.info("Find per-resource thread pool with key: " + key);
executorService = _executorMap.get(key);
}
}
}
}
return executorService;
}
示例2: onBecomeOnlineFromOffline
import org.apache.helix.model.Message; //导入方法依赖的package包/类
@Transition(to = "ONLINE", from = "OFFLINE")
public void onBecomeOnlineFromOffline(Message message, NotificationContext context)
throws Exception {
LOG.debug(_workerId + " becomes ONLINE from OFFLINE for " + _partition);
ConfigAccessor clusterConfig = context.getManager().getConfigAccessor();
HelixManager manager = context.getManager();
HelixConfigScope clusterScope =
new HelixConfigScopeBuilder(ConfigScopeProperty.CLUSTER).forCluster(
manager.getClusterName()).build();
String json = clusterConfig.get(clusterScope, message.getResourceName());
Dag.Node node = Dag.Node.fromJson(json);
Set<String> parentIds = node.getParentIds();
String resourceName = message.getResourceName();
int numPartitions = node.getNumPartitions();
Task task = _taskFactory.createTask(resourceName, parentIds, manager, _taskResultStore);
manager.addExternalViewChangeListener(task);
LOG.debug("Starting task for " + _partition + "...");
int partitionNum = Integer.parseInt(_partition.split("_")[1]);
task.execute(resourceName, numPartitions, partitionNum);
LOG.debug("Task for " + _partition + " done");
}
示例3: onBecomeOnlineFromOffline
import org.apache.helix.model.Message; //导入方法依赖的package包/类
@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, /*retryOnFailure=*/true);
} 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);
}
}
示例4: onBecomeDroppedFromOffline
import org.apache.helix.model.Message; //导入方法依赖的package包/类
@Transition(from = "OFFLINE", to = "DROPPED")
public void onBecomeDroppedFromOffline(Message message, NotificationContext context) {
_logger.info("SegmentOnlineOfflineStateModel.onBecomeDroppedFromOffline() : " + message);
final String segmentId = message.getPartitionName();
final String tableName = message.getResourceName();
try {
final File segmentDir = new File(_fetcherAndLoader.getSegmentLocalDirectory(tableName, segmentId));
if (segmentDir.exists()) {
FileUtils.deleteQuietly(segmentDir);
_logger.info("Deleted segment directory {}", segmentDir);
}
} catch (final Exception e) {
_logger.error("Cannot delete the segment : " + segmentId + " from local directory!\n" + e.getMessage(), e);
Utils.rethrowException(e);
}
}
示例5: onBecomeOfflineFromOnline
import org.apache.helix.model.Message; //导入方法依赖的package包/类
@Transition(from = "ONLINE", to = "OFFLINE")
public void onBecomeOfflineFromOnline(Message message, NotificationContext context) {
try {
LOGGER.info("BrokerResourceOnlineOfflineStateModel.onBecomeOfflineFromOnline() : " + message);
String resourceName = message.getResourceName();
_helixExternalViewBasedRouting.markDataResourceOffline(resourceName);
} catch (Exception e) {
LOGGER.error("Caught exception during ONLINE -> OFFLINE transition", e);
Utils.rethrowException(e);
throw new AssertionError("Should not reach this");
}
}
示例6: onBecomeDroppedFromOffline
import org.apache.helix.model.Message; //导入方法依赖的package包/类
@Transition(from = "OFFLINE", to = "DROPPED")
public void onBecomeDroppedFromOffline(Message message, NotificationContext context) {
try {
LOGGER.info("BrokerResourceOnlineOfflineStateModel.onBecomeDroppedFromOffline() : " + message);
String resourceName = message.getResourceName();
_helixExternalViewBasedRouting.markDataResourceOffline(resourceName);
} catch (Exception e) {
LOGGER.error("Caught exception during OFFLINE -> DROPPED transition", e);
Utils.rethrowException(e);
throw new AssertionError("Should not reach this");
}
}
示例7: onBecomeDroppedFromOnline
import org.apache.helix.model.Message; //导入方法依赖的package包/类
@Transition(from = "ONLINE", to = "DROPPED")
public void onBecomeDroppedFromOnline(Message message, NotificationContext context) {
try {
LOGGER.info("BrokerResourceOnlineOfflineStateModel.onBecomeDroppedFromOnline() : " + message);
String resourceName = message.getResourceName();
_helixExternalViewBasedRouting.markDataResourceOffline(resourceName);
} catch (Exception e) {
LOGGER.error("Caught exception during ONLINE -> DROPPED transition", e);
Utils.rethrowException(e);
throw new AssertionError("Should not reach this");
}
}
示例8: onBecomeOnlineFromOfflineForRealtimeSegment
import org.apache.helix.model.Message; //导入方法依赖的package包/类
private void onBecomeOnlineFromOfflineForRealtimeSegment(Message message, NotificationContext context)
throws Exception {
final String segmentId = message.getPartitionName();
final String tableName = message.getResourceName();
SegmentZKMetadata realtimeSegmentZKMetadata =
ZKMetadataProvider.getRealtimeSegmentZKMetadata(propertyStore, tableName, segmentId);
InstanceZKMetadata instanceZKMetadata = ZKMetadataProvider.getInstanceZKMetadata(propertyStore, _instanceId);
AbstractTableConfig tableConfig = ZKMetadataProvider.getRealtimeTableConfig(propertyStore, tableName);
((InstanceDataManager) INSTANCE_DATA_MANAGER).addSegment(propertyStore, tableConfig, instanceZKMetadata,
realtimeSegmentZKMetadata);
}
示例9: onBecomeDroppedFromOffline
import org.apache.helix.model.Message; //导入方法依赖的package包/类
@Transition(from = "OFFLINE", to = "DROPPED")
public void onBecomeDroppedFromOffline(Message message, NotificationContext context) {
LOGGER.debug("SegmentOnlineOfflineStateModel.onBecomeDroppedFromOffline() : " + message);
final String segmentId = message.getPartitionName();
final String tableName = message.getResourceName();
try {
final File segmentDir = new File(getSegmentLocalDirectory(tableName, segmentId));
if (segmentDir.exists()) {
FileUtils.deleteQuietly(segmentDir);
}
} catch (final Exception e) {
LOGGER.error("Cannot delete the segment : " + segmentId + " from local directory!\n" + e.getMessage(), e);
Utils.rethrowException(e);
}
}
示例10: reportMessageStat
import org.apache.helix.model.Message; //导入方法依赖的package包/类
private void reportMessageStat(HelixManager manager, Message message, HelixTaskResult taskResult) {
// report stat
if (!message.getMsgType().equals(MessageType.STATE_TRANSITION.name())) {
return;
}
long now = new Date().getTime();
long msgReadTime = message.getReadTimeStamp();
long msgExecutionStartTime = message.getExecuteStartTimeStamp();
if (msgReadTime != 0 && msgExecutionStartTime != 0) {
long totalDelay = now - msgReadTime;
long executionDelay = now - msgExecutionStartTime;
if (totalDelay > 0 && executionDelay > 0) {
String fromState = message.getFromState();
String toState = message.getToState();
String transition = fromState + "--" + toState;
StateTransitionContext cxt =
new StateTransitionContext(manager.getClusterName(), manager.getInstanceName(),
message.getResourceName(), transition);
StateTransitionDataPoint data =
new StateTransitionDataPoint(totalDelay, executionDelay, taskResult.isSuccess());
_executor.getParticipantMonitor().reportTransitionStat(cxt, data);
}
} else {
logger.warn("message read time and start execution time not recorded.");
}
}
示例11: getStatusUpdateSubPath
import org.apache.helix.model.Message; //导入方法依赖的package包/类
/**
* Generate the sub-path under STATUSUPDATE or ERROR path for a status update
*/
String getStatusUpdateSubPath(Message message) {
if (message.getMsgType().equalsIgnoreCase(MessageType.STATE_TRANSITION.name())) {
return message.getResourceName();
}
return message.getMsgType();
}
示例12: onBecomeOnlineFromConsuming
import org.apache.helix.model.Message; //导入方法依赖的package包/类
@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);
TableDataManager tableDataManager = _instanceDataManager.getTableDataManager(realtimeTableName);
Preconditions.checkNotNull(tableDataManager);
SegmentDataManager acquiredSegment = tableDataManager.acquireSegment(segmentNameStr);
// For this transition to be correct in helix, we should already have a segment that is consuming
if (acquiredSegment == null) {
throw new RuntimeException("Segment " + segmentNameStr + " + not present ");
}
try {
if (!(acquiredSegment instanceof LLRealtimeSegmentDataManager)) {
// We found a LLC segment that is not consuming right now, must be that we already swapped it with a
// segment that has been built. Nothing to do for this state transition.
_logger.info(
"Segment {} not an instance of LLRealtimeSegmentDataManager. Reporting success for the transition",
acquiredSegment.getSegmentName());
return;
}
LLRealtimeSegmentDataManager segmentDataManager = (LLRealtimeSegmentDataManager) acquiredSegment;
RealtimeSegmentZKMetadata metadata =
ZKMetadataProvider.getRealtimeSegmentZKMetadata(_propertyStore, segmentName.getTableName(), segmentNameStr);
segmentDataManager.goOnlineFromConsuming(metadata);
} catch (InterruptedException e) {
_logger.warn("State transition interrupted", e);
throw new RuntimeException(e);
} finally {
tableDataManager.releaseSegment(acquiredSegment);
}
}
示例13: onBecomeOfflineFromConsuming
import org.apache.helix.model.Message; //导入方法依赖的package包/类
@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);
}
}
示例14: onBecomeOfflineFromOnline
import org.apache.helix.model.Message; //导入方法依赖的package包/类
@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);
}
}
示例15: getStatusUpdateRecordName
import org.apache.helix.model.Message; //导入方法依赖的package包/类
String getStatusUpdateRecordName(Message message) {
if (message.getMsgType().equalsIgnoreCase(MessageType.STATE_TRANSITION.name())) {
return message.getTgtSessionId() + "__" + message.getResourceName();
}
return message.getMsgId();
}