Java tutorial
/* * Copyright (C) 2010-2101 Alibaba Group Holding Limited. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.alibaba.otter.shared.arbitrate.impl.manage.helper; import java.text.MessageFormat; import org.apache.commons.lang.StringUtils; import com.alibaba.otter.shared.arbitrate.impl.ArbitrateConstants; /** * zookeeper pathhelper * * @author jianghang */ public class ManagePathUtils { /** * otter root path */ public static String getRoot() { return ArbitrateConstants.NODE_OTTER_ROOT; } /** * node root path */ public static String getNodeRoot() { return ArbitrateConstants.NODE_NID_ROOT; } /** * channel root path */ public static String getChannelRoot() { return ArbitrateConstants.NODE_CHANNEL_ROOT; } /** * node path */ public static String getNode(Long nodeId) { // ?nodeIdpath return MessageFormat.format(ArbitrateConstants.NODE_NID_FORMAT, String.valueOf(nodeId)); } /** * channel path (??config?) */ public static String getChannelByChannelId(Long channelId) { // ?channelId path return MessageFormat.format(ArbitrateConstants.NODE_CHANNEL_FORMAT, String.valueOf(channelId)); } /** * pipeline path (??config?) */ public static String getPipeline(Long channelId, Long pipelineId) { // ?channelId , pipelineId path return MessageFormat.format(ArbitrateConstants.NODE_PIPELINE_FORMAT, String.valueOf(channelId), String.valueOf(pipelineId)); } /** * remedy root path */ public static String getRemedyRoot(Long channelId, Long pipelineId) { // ?channelId , pipelineIdpath return MessageFormat.format(ArbitrateConstants.NODE_REMEDY_ROOT, String.valueOf(channelId), String.valueOf(pipelineId)); } /** * getProcess path (??config?) */ public static String getProcessRoot(Long channelId, Long pipelineId) { // ?channelId , pipelineId path return MessageFormat.format(ArbitrateConstants.NODE_PROCESS_ROOT, String.valueOf(channelId), String.valueOf(pipelineId)); } /** * mainStem path */ public static String getMainStem(Long channelId, Long pipelineId) { return MessageFormat.format(ArbitrateConstants.NODE_PIPELINE_FORMAT, String.valueOf(channelId), String.valueOf(pipelineId)) + "/" + ArbitrateConstants.NODE_MAINSTEM; } /** * termin root path(??config?) */ public static String getTerminRoot(Long channelId, Long pipelineId) { // ?channelId , pipelineIdpath return MessageFormat.format(ArbitrateConstants.NODE_TERMIN_ROOT, String.valueOf(channelId), String.valueOf(pipelineId)); } /** * process path */ public static String getProcess(Long channelId, Long pipelineId, Long processId) { // ?channelId , pipelineIdpath return MessageFormat.format(ArbitrateConstants.NODE_PROCESS_FORMAT, String.valueOf(channelId), String.valueOf(pipelineId), getProcessNode(processId)); } /** * process path */ public static String getProcess(Long channelId, Long pipelineId, String processNode) { // ?channelId , pipelineIdpath return MessageFormat.format(ArbitrateConstants.NODE_PROCESS_FORMAT, String.valueOf(channelId), String.valueOf(pipelineId), processNode); } /** * termin path */ public static String getTermin(Long channelId, Long pipelineId, Long processId) { // ?channelId , pipelineIdpath return MessageFormat.format(ArbitrateConstants.NODE_TERMIN_FORMAT, String.valueOf(channelId), String.valueOf(pipelineId), getProcessNode(processId)); } /** * lock root path(??config?) */ public static String getLockRoot(Long channelId, Long pipelineId) { // ?channelId , pipelineIdpath return MessageFormat.format(ArbitrateConstants.NODE_LOCK_ROOT, String.valueOf(channelId), String.valueOf(pipelineId)); } // ======================== hleper method============================ /** * zookeepernode??processId */ public static Long getProcessId(String processNode) { return Long.valueOf(processNode); } /** * processIdzookeepernode?? */ public static String getProcessNode(Long processId) { return StringUtils.leftPad(String.valueOf(processId.intValue()), 10, '0'); } }