Example usage for java.util SortedMap get

List of usage examples for java.util SortedMap get

Introduction

In this page you can find the example usage for java.util SortedMap get.

Prototype

V get(Object key);

Source Link

Document

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

Usage

From source file:com.aurel.track.fieldType.bulkSetters.CompositeSelectBulkSetter.java

/**
 * The JSON configuration object for configuring the js control(s) containing the value
 * @param baseName: the name of the control: important by submit
 * @param value: the value to be set by rendering (first time or after a submit)
 * @param dataSource: defined only for lists (list for global lists, map for context dependent lists)
 * @param labelMap: defined only for context (project/issuType) dependent lists
 * @param disabled: whether the control is disabled
  * @param personBean/*from  ww w  .j  av  a2s . c o  m*/
 * @param locale
 * @return
 */
@Override
public String getSetterValueJsonConfig(String baseName, Object value, Object dataSource,
        Map<Integer, String> labelMap, boolean disabled, TPersonBean personBean, Locale locale) {
    Integer fieldID = getFieldID();
    StringBuilder stringBuilder = new StringBuilder("{");
    //it will be the itemId of the panel, needed for removing the panel after setter change 
    JSONUtility.appendStringValue(stringBuilder, JSONUtility.JSON_FIELDS.NAME, getName(baseName));
    CustomCompositeBaseRT compositeBaseRT = (CustomCompositeBaseRT) FieldTypeManager.getFieldTypeRT(fieldID);
    if (compositeBaseRT != null) {
        Map<Integer, SortedMap<Integer, List<ILabelBean>>> dataSourceMap = (Map<Integer, SortedMap<Integer, List<ILabelBean>>>) dataSource;
        if (dataSourceMap != null) {
            boolean allIssuesFromTheSameProject = dataSourceMap.keySet().size() == 1;
            Map<Integer, SortedMap<Integer, Integer[]>> valueMap = (Map<Integer, SortedMap<Integer, Integer[]>>) value;
            JSONUtility.appendFieldName(stringBuilder, "listsJson").append(":[");
            for (Iterator<Integer> itrList = dataSourceMap.keySet().iterator(); itrList.hasNext();) {
                stringBuilder.append("{");
                Integer listID = itrList.next();
                SortedMap<Integer, List<ILabelBean>> compositeListDataSource = dataSourceMap.get(listID);
                if (compositeListDataSource != null) {
                    SortedMap<Integer, Integer[]> compositeListValue = null;
                    if (valueMap != null) {
                        compositeListValue = valueMap.get(listID);
                    }
                    if (labelMap != null && !allIssuesFromTheSameProject) {
                        JSONUtility.appendStringValue(stringBuilder, JSONUtility.JSON_FIELDS.LABEL,
                                labelMap.get(listID));
                    }
                    JSONUtility.appendIntegerValue(stringBuilder, "listID", listID);
                    JSONUtility.appendFieldName(stringBuilder, "parts").append(":[");
                    for (Iterator<Integer> itrPart = compositeListDataSource.keySet().iterator(); itrPart
                            .hasNext();) {
                        Integer parameterCode = itrPart.next();
                        List<ILabelBean> partDataSource = compositeListDataSource.get(parameterCode);
                        stringBuilder.append("{");
                        JSONUtility.appendStringValue(stringBuilder, JSONUtility.JSON_FIELDS.NAME,
                                getNameWithMergedKey(baseName, fieldID, listID, parameterCode));
                        JSONUtility.appendStringValue(stringBuilder, JSONUtility.JSON_FIELDS.ITEMID,
                                getItemIdWithMergedKey(MassOperationBL.VALUE_BASE_ITEMID, fieldID, listID,
                                        parameterCode));
                        JSONUtility.appendILabelBeanList(stringBuilder, JSONUtility.JSON_FIELDS.DATA_SOURCE,
                                partDataSource);
                        Integer[] listValues = null;
                        Integer listValue = null;
                        if (compositeListValue != null) {
                            listValues = compositeListValue.get(parameterCode);
                            if (listValues != null && listValues.length > 0) {
                                listValue = listValues[0];
                            }
                        }
                        if (listValue == null) {
                            if (partDataSource != null && !partDataSource.isEmpty()) {
                                listValue = partDataSource.get(0).getObjectID();
                            }
                        }
                        if (listValue != null) {
                            JSONUtility.appendIntegerValue(stringBuilder, JSONUtility.JSON_FIELDS.VALUE,
                                    listValue, true);
                        }
                        stringBuilder.append("}");
                        if (itrPart.hasNext()) {
                            stringBuilder.append(",");
                        }
                    }
                    stringBuilder.append("]");
                    stringBuilder.append("}");
                    if (itrList.hasNext()) {
                        stringBuilder.append(",");
                    }
                }
            }
            stringBuilder.append("],");
        }
        JSONUtility.appendBooleanValue(stringBuilder, JSONUtility.JSON_FIELDS.DISABLED, disabled, true);
    }
    stringBuilder.append("}");
    return stringBuilder.toString();
}

From source file:se.jguru.nazgul.tools.codestyle.enforcer.rules.CorrectPackagingRule.java

/**
 * Delegate method, implemented by concrete subclasses.
 *
 * @param project The active MavenProject.
 * @param helper  The EnforcerRuleHelper instance, from which the MavenProject has been retrieved.
 * @throws RuleFailureException If the enforcer rule was not satisfied.
 *///from  w w  w  .  j a  va2s  .c  om
@Override
@SuppressWarnings("unchecked")
protected void performValidation(final MavenProject project, final EnforcerRuleHelper helper)
        throws RuleFailureException {

    // Find all java source files, and map their packages to their names.
    final List<String> compileSourceRoots = (List<String>) project.getCompileSourceRoots();
    if (compileSourceRoots.size() == 0) {
        return;
    }

    final SortedMap<String, SortedSet<String>> packageName2SourceFileNameMap = new TreeMap<String, SortedSet<String>>();

    for (String current : compileSourceRoots) {
        addPackages(new File(current), packageName2SourceFileNameMap);
    }

    // Retrieve the groupId of this project
    final String groupId = project.getGroupId();
    if (groupId == null || groupId.equals("")) {

        // Don't accept empty groupIds
        throw new RuleFailureException("Maven groupId cannot be null or empty.", project.getArtifact());

    } else {

        // Correct packaging everywhere?
        final SortedSet<String> incorrectPackages = new TreeSet<String>();
        for (Map.Entry<String, SortedSet<String>> currentPackage : packageName2SourceFileNameMap.entrySet()) {

            final String candidate = currentPackage.getKey();
            if (!candidate.startsWith(groupId)) {
                incorrectPackages.add(candidate);
            }
        }

        if (incorrectPackages.size() > 0) {

            final SortedMap<String, SortedSet<String>> result = new TreeMap<String, SortedSet<String>>();
            for (String current : incorrectPackages) {
                result.put(current, packageName2SourceFileNameMap.get(current));
            }

            throw new RuleFailureException("Incorrect packaging detected; required [" + groupId
                    + "] but found package to file names: " + result, project.getArtifact());
        }
    }
}

From source file:org.wso2.carbon.identity.oauth2.authcontext.JWTTokenGenerator.java

/**
 * Method that generates the JWT./*from w w  w.  j  a  v  a2s .c  o m*/
 *
 * @return signed JWT token
 * @throws IdentityOAuth2Exception
 */
@Override
public void generateToken(OAuth2TokenValidationMessageContext messageContext) throws IdentityOAuth2Exception {

    String clientId = ((AccessTokenDO) messageContext.getProperty("AccessTokenDO")).getConsumerKey();
    long issuedTime = ((AccessTokenDO) messageContext.getProperty("AccessTokenDO")).getIssuedTime().getTime();
    String authzUser = messageContext.getResponseDTO().getAuthorizedUser();
    int tenantID = ((AccessTokenDO) messageContext.getProperty("AccessTokenDO")).getTenantID();
    String tenantDomain = OAuth2Util.getTenantDomain(tenantID);
    boolean isExistingUser = false;

    RealmService realmService = OAuthComponentServiceHolder.getRealmService();
    // TODO : Need to handle situation where federated user name is similar to a one we have in our user store
    if (realmService != null && tenantID != MultitenantConstants.INVALID_TENANT_ID
            && tenantID == OAuth2Util.getTenantIdFromUserName(authzUser)) {
        try {
            UserRealm userRealm = realmService.getTenantUserRealm(tenantID);
            if (userRealm != null) {
                UserStoreManager userStoreManager = (UserStoreManager) userRealm.getUserStoreManager();
                isExistingUser = userStoreManager
                        .isExistingUser(MultitenantUtils.getTenantAwareUsername(authzUser));
            }
        } catch (UserStoreException e) {
            log.error("Error occurred while loading the realm service", e);
        }
    }

    OAuthAppDAO appDAO = new OAuthAppDAO();
    OAuthAppDO appDO;
    try {
        appDO = appDAO.getAppInformation(clientId);
        // Adding the OAuthAppDO as a context property for further use
        messageContext.addProperty("OAuthAppDO", appDO);
    } catch (IdentityOAuth2Exception e) {
        log.debug(e.getMessage(), e);
        throw new IdentityOAuth2Exception(e.getMessage());
    } catch (InvalidOAuthClientException e) {
        log.debug(e.getMessage(), e);
        throw new IdentityOAuth2Exception(e.getMessage());
    }
    String subscriber = appDO.getUserName();
    String applicationName = appDO.getApplicationName();

    //generating expiring timestamp
    long currentTime = Calendar.getInstance().getTimeInMillis();
    long expireIn = currentTime + 1000 * 60 * getTTL();

    // Prepare JWT with claims set
    JWTClaimsSet claimsSet = new JWTClaimsSet();
    claimsSet.setIssuer(API_GATEWAY_ID);
    claimsSet.setSubject(authzUser);
    claimsSet.setIssueTime(new Date(issuedTime));
    claimsSet.setExpirationTime(new Date(expireIn));
    claimsSet.setClaim(API_GATEWAY_ID + "/subscriber", subscriber);
    claimsSet.setClaim(API_GATEWAY_ID + "/applicationname", applicationName);
    claimsSet.setClaim(API_GATEWAY_ID + "/enduser", authzUser);

    if (claimsRetriever != null) {

        //check in local cache
        String[] requestedClaims = messageContext.getRequestDTO().getRequiredClaimURIs();
        if (requestedClaims == null && isExistingUser) {
            // if no claims were requested, return all
            requestedClaims = claimsRetriever.getDefaultClaims(authzUser);
        }

        CacheKey cacheKey = null;
        Object result = null;

        if (requestedClaims != null) {
            cacheKey = new ClaimCacheKey(authzUser, requestedClaims);
            result = claimsLocalCache.getValueFromCache(cacheKey);
        }

        SortedMap<String, String> claimValues = null;
        if (result != null) {
            claimValues = ((UserClaims) result).getClaimValues();
        } else if (isExistingUser) {
            claimValues = claimsRetriever.getClaims(authzUser, requestedClaims);
            UserClaims userClaims = new UserClaims(claimValues);
            claimsLocalCache.addToCache(cacheKey, userClaims);
        }

        if (isExistingUser) {
            String claimSeparator = getMultiAttributeSeparator(authzUser, tenantID);
            if (StringUtils.isBlank(claimSeparator)) {
                userAttributeSeparator = claimSeparator;
            }
        }

        if (claimValues != null) {
            Iterator<String> it = new TreeSet(claimValues.keySet()).iterator();
            while (it.hasNext()) {
                String claimURI = it.next();
                String claimVal = claimValues.get(claimURI);
                List<String> claimList = new ArrayList<String>();
                if (userAttributeSeparator != null && claimVal.contains(userAttributeSeparator)) {
                    StringTokenizer st = new StringTokenizer(claimVal, userAttributeSeparator);
                    while (st.hasMoreElements()) {
                        String attValue = st.nextElement().toString();
                        if (StringUtils.isNotBlank(attValue)) {
                            claimList.add(attValue);
                        }
                    }
                    claimsSet.setClaim(claimURI, claimList.toArray(new String[claimList.size()]));
                } else {
                    claimsSet.setClaim(claimURI, claimVal);
                }
            }
        }
    }

    JWT jwt = null;
    if (!JWSAlgorithm.NONE.equals(signatureAlgorithm)) {
        JWSHeader header = new JWSHeader(JWSAlgorithm.RS256);
        header.setX509CertThumbprint(new Base64URL(getThumbPrint(tenantDomain, tenantID)));
        jwt = new SignedJWT(header, claimsSet);
        jwt = signJWT((SignedJWT) jwt, tenantDomain, tenantID);
    } else {
        jwt = new PlainJWT(claimsSet);
    }

    if (log.isDebugEnabled()) {
        log.debug("JWT Assertion Value : " + jwt.serialize());
    }
    OAuth2TokenValidationResponseDTO.AuthorizationContextToken token;
    token = messageContext.getResponseDTO().new AuthorizationContextToken("JWT", jwt.serialize());
    messageContext.getResponseDTO().setAuthorizationContextToken(token);
}

From source file:edu.usc.pgroup.louvain.hadoop.ReduceCommunity.java

private Graph reconstructGraph(Iterable<BytesWritable> values) throws Exception {

    Iterator<BytesWritable> it = values.iterator();

    SortedMap<Integer, GraphMessage> map = new TreeMap<Integer, GraphMessage>();

    //Load data//  ww w  .java 2s  . com
    while (it.hasNext()) {
        BytesWritable bytesWritable = it.next();
        ByteArrayInputStream inputStream = new ByteArrayInputStream(bytesWritable.getBytes());

        try {
            ObjectInputStream objectInputStream = new ObjectInputStream(inputStream);
            GraphMessage msg = (GraphMessage) objectInputStream.readObject();
            map.put(msg.getCurrentPartition(), msg);
        } catch (IOException e) {
            e.printStackTrace();
            throw new Exception(e);
        }

    }

    // Renumber

    int gap = 0;
    int degreeGap = 0;
    Path pt = new Path(outpath + File.separator + "Map-Partition-Sizes");
    FileSystem fs = FileSystem.get(new Configuration());

    if (fs.exists(pt)) {
        fs.delete(pt, true);

    }

    BufferedWriter br = new BufferedWriter(new OutputStreamWriter(fs.create(pt, true)));

    PrintWriter out = new PrintWriter(br);

    for (int i = 0; i < map.keySet().size(); i++) {

        GraphMessage msg = map.get(i);
        long currentDegreelen = msg.getDegrees()[msg.getDegrees().length - 1];
        if (i != 0) {
            for (int j = 0; j < msg.getLinks().length; j++) {
                msg.getLinks()[j] += gap;
            }

            for (int j = 0; j < msg.getRemoteMap().length; j++) {
                msg.getRemoteMap()[j].source += gap;
            }

            for (int j = 0; j < msg.getN2c().length; j++) {
                msg.getN2c()[j] += gap;
            }

            for (int j = 0; j < msg.getDegrees().length; j++) {
                msg.getDegrees()[j] += degreeGap;

            }

        }

        out.println("" + i + "," + msg.getNb_nodes());
        gap += msg.getNb_nodes();
        degreeGap += currentDegreelen;
    }

    out.flush();
    out.close();
    //Integrate

    Graph graph = new Graph();

    for (int i = 0; i < map.keySet().size(); i++) {
        GraphMessage msg = map.get(i);

        Collections.addAll(graph.getDegrees().getList(), msg.getDegrees());
        Collections.addAll(graph.getLinks().getList(), msg.getLinks());
        Collections.addAll(graph.getWeights().getList(), msg.getWeights());

        graph.setNb_links(graph.getNb_links() + msg.getNb_links());
        graph.setNb_nodes((int) (graph.getNb_nodes() + msg.getNb_nodes()));
        graph.setTotal_weight(graph.getTotal_weight() + msg.getTotal_weight());

    }

    //Merge local done.

    Map<Integer, Vector<Integer>> remoteEdges = new HashMap<Integer, Vector<Integer>>();
    Map<Integer, Vector<Float>> remoteWeighs = new HashMap<Integer, Vector<Float>>();

    for (int i = 0; i < map.keySet().size(); i++) {
        Map<HashMap.SimpleEntry<Integer, Integer>, Float> m = new HashMap<AbstractMap.SimpleEntry<Integer, Integer>, Float>();

        GraphMessage msg = map.get(i);
        for (int j = 0; j < msg.getRemoteMap().length; j++) {

            RemoteMap remoteMap = msg.getRemoteMap()[j];

            int sink = remoteMap.sink;
            int sinkPart = remoteMap.sinkPart;

            int target = map.get(sinkPart).getN2c()[sink];

            HashMap.SimpleEntry<Integer, Integer> key = new HashMap.SimpleEntry<Integer, Integer>(
                    remoteMap.source, target);
            if (m.containsKey(key)) {
                m.put(key, m.get(key) + 1.0f);
            } else {
                m.put(key, 1.0f);
            }
        }

        graph.setNb_links(graph.getNb_links() + m.size());

        Iterator<HashMap.SimpleEntry<Integer, Integer>> itr = m.keySet().iterator();

        while (itr.hasNext()) {

            HashMap.SimpleEntry<Integer, Integer> key = itr.next();
            float w = m.get(key);

            if (remoteEdges.containsKey(key.getKey())) {

                remoteEdges.get(key.getKey()).getList().add(key.getValue());

                if (remoteWeighs.containsKey(key.getKey())) {
                    remoteWeighs.get(key.getKey()).getList().add(w);
                }

            } else {
                Vector<Integer> list = new Vector<Integer>();
                list.getList().add(key.getValue());
                remoteEdges.put(key.getKey(), list);

                Vector<Float> wList = new Vector<Float>();
                wList.getList().add(w);
                remoteWeighs.put(key.getKey(), wList);
            }

        }

    }

    graph.addRemoteEdges(remoteEdges, remoteWeighs);

    //Merge Remote Done

    return graph;

}

From source file:jp.zippyzip.web.ListServlet.java

void setBuilding(HttpServletRequest request, ParentChild data, SortedMap<String, Pref> prefs,
        SortedMap<String, City> cities) throws JSONException {

    LinkedList<ListItem> list = new LinkedList<ListItem>();
    LinkedList<BreadCrumb> breadCrumbs = new LinkedList<BreadCrumb>();
    String x0402 = "";

    breadCrumbs.add(new BreadCrumb("prefs", PAGE_TITLE));
    breadCrumbs.add(new BreadCrumb(null, "??"));

    request.setAttribute("breadCrumbs", breadCrumbs);
    request.setAttribute("br", "");

    for (String json : data.getChildren()) {

        Zip zip = Zip.fromJson(json);/*from   w  ww.  ja  v a  2s . co  m*/

        if (!x0402.equals(zip.getX0402())) {

            x0402 = zip.getX0402();

            list.add(new ListItem(null, "", "",
                    prefs.get(x0402.subSequence(0, 2)).getName() + "" + cities.get(x0402).getName(), "", ""));
        }

        int sep = zip.getAdd1().indexOf(" ");
        String add1 = (sep < 0) ? "" : zip.getAdd1().substring(0, sep);
        String name = zip.getAdd1().substring(sep + 1);

        sep = zip.getAdd1Yomi().indexOf(" ");

        list.add(new ListItem(zip.getX0402() + "-" + toHex(add1 + name), null, null, name,
                zip.getAdd1Yomi().substring(sep + 1), null));
    }

    request.setAttribute("list", list);
    request.setAttribute("timestamp", data.getTimestamp());
}

From source file:hudson.model.Job.java

/**
 * Returns the last build.//  w w  w. j a  v a2  s .  c  o  m
 * @see LazyBuildMixIn#getLastBuild
 */
@Exported
@QuickSilver
public RunT getLastBuild() {
    SortedMap<Integer, ? extends RunT> runs = _getRuns();

    if (runs.isEmpty())
        return null;
    return runs.get(runs.firstKey());
}

From source file:hudson.model.Job.java

/**
 * Returns the oldest build in the record.
 * @see LazyBuildMixIn#getFirstBuild//www  .j  a  v  a2 s .  c  om
 */
@Exported
@QuickSilver
public RunT getFirstBuild() {
    SortedMap<Integer, ? extends RunT> runs = _getRuns();

    if (runs.isEmpty())
        return null;
    return runs.get(runs.lastKey());
}

From source file:com.aurel.track.fieldType.runtime.matchers.run.CompositeSelectMatcherRT.java

/**
 * Whether the value matches or not/*from   ww  w  .j a  v  a  2 s. c  om*/
 * @param attributeValue
 * @return
 */
@Override
public boolean match(Object attributeValue) {
    Boolean nullMatch = nullMatcher(attributeValue);
    if (nullMatch != null) {
        return nullMatch.booleanValue();
    }
    if (attributeValue == null || matchValue == null) {
        return false;
    }
    Map<Integer, Object> attributeValueMap = null;
    try {
        attributeValueMap = (Map<Integer, Object>) attributeValue;
    } catch (Exception e) {
        LOGGER.warn("Converting the attribute value of type " + attributeValue.getClass().getName()
                + " to Map<Integer, Object failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    SortedMap<Integer, Object> matcherValueMap = null;
    try {
        matcherValueMap = (SortedMap<Integer, Object>) matchValue;
    } catch (Exception e) {
        LOGGER.warn("Converting the matcher value of type " + matchValue.getClass().getName()
                + " to SortedMap<Integer, Object> failed with " + e.getMessage());
        LOGGER.debug(ExceptionUtils.getStackTrace(e));
    }
    if (attributeValueMap == null || matcherValueMap == null) {
        return false;
    }
    Iterator<Integer> iterator = matcherValueMap.keySet().iterator();
    while (iterator.hasNext()) {
        Integer parameterCode = iterator.next();
        Object[] attributeValueCustomOption = null;
        try {
            attributeValueCustomOption = (Object[]) attributeValueMap.get(parameterCode);
        } catch (Exception e) {
            LOGGER.warn("Converting the attribute value for part " + parameterCode + " to Object[] failed with "
                    + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
            return false;
        }
        Integer[] matcherValueCustomOption = null;
        try {
            matcherValueCustomOption = (Integer[]) matcherValueMap.get(parameterCode);
        } catch (Exception e) {
            LOGGER.error("Converting the matcher value for part " + parameterCode + " to Integer[] failed with "
                    + e.getMessage());
            LOGGER.debug(ExceptionUtils.getStackTrace(e));
            return false;
        }

        if (attributeValueCustomOption == null) {
            attributeValueCustomOption = new Object[0];
        }
        if (matcherValueCustomOption == null) {
            matcherValueCustomOption = new Integer[0];
        }
        if (attributeValueCustomOption.length != matcherValueCustomOption.length) {
            return false;
        }

        if (matcherValueCustomOption.length == 0) {
            return matcherValueCustomOption.length == 0;
        }
        Integer matcherValueAtLevel = matcherValueCustomOption[0];
        switch (relation) {
        case MatchRelations.EQUAL:
            if (!containsValue(matcherValueAtLevel, attributeValueCustomOption)) {
                return false;
            }
            break;
        case MatchRelations.NOT_EQUAL:
            if (!containsValue(matcherValueAtLevel, attributeValueCustomOption)) {
                return true;
            }
            break;
        case MatchRelations.PARTIAL_MATCH:
            if (matcherValueAtLevel.equals(ANY_FROM_LEVEL)) {
                return true;
            } else {
                if (!containsValue(matcherValueAtLevel, attributeValueCustomOption)) {
                    return false;
                }
            }
            break;
        case MatchRelations.PARTIAL_NOTMATCH:
            if (!containsValue(matcherValueAtLevel, attributeValueCustomOption)
                    && !matcherValueCustomOption[0].equals(NONE_FROM_LEVEL)) {
                return true;
            }
            break;
        default:
            return false;
        }
    }
    if (relation == MatchRelations.NOT_EQUAL || relation == MatchRelations.PARTIAL_NOTMATCH) {
        return false;
    } else {
        return true;
    }
}

From source file:hudson.model.Job.java

/**
 * Gets the latest build #m that satisfies <tt>m&lt;=n</tt>.
 * //  ww w. jav  a 2  s.co  m
 * This is useful when you'd like to fetch a build but the exact build might
 * be already gone (deleted, rotated, etc.)
 * @see LazyBuildMixIn#getNearestOldBuild
 */
public RunT getNearestOldBuild(int n) {
    SortedMap<Integer, ? extends RunT> m = _getRuns().tailMap(n);
    if (m.isEmpty())
        return null;
    return m.get(m.firstKey());
}

From source file:okuyama.imdst.util.DataDispatcher.java

/**
 * Rule?????????KeyNode?????????.<br>
 * ConsistentHash.<br>/*from  w w  w . j  av  a 2  s .  c o m*/
 * ????????????????6?Third????9??<br>
 *
 * @param key 
 * @param useOldCircle 
 * @return String[] ?(??????)
 */
private static String[] decisionConsistentHashKeyNode(String key, boolean useOldCircle) {
    String[] ret = null;
    boolean noWaitFlg = false;
    SortedMap useNodeCircle = null;
    String targetNode = null;
    String[] mainDataNodeInfo = null;
    String[] slaveDataNodeInfo = null;
    String[] thirdDataNodeInfo = null;

    // ??
    String[][] allNodeDetailList = (String[][]) keyNodeMap.get("list");

    // Key?Hash?
    int execKeyInt = sha1Hash4Int(key);

    // ??
    // useOldCircle???????
    if (useOldCircle && oldCircle != null) {
        useNodeCircle = oldCircle;
    } else {
        useNodeCircle = nodeCircle;
    }

    // ?
    int hash = sha1Hash4Int(key);

    if (!useNodeCircle.containsKey(hash)) {
        SortedMap<Integer, Map> tailMap = useNodeCircle.tailMap(hash);
        if (tailMap.isEmpty()) {
            hash = ((Integer) useNodeCircle.firstKey()).intValue();
        } else {
            hash = ((Integer) tailMap.firstKey()).intValue();
        }
    }

    // ???
    targetNode = (String) useNodeCircle.get(hash);

    // ??
    mainDataNodeInfo = (String[]) keyNodeMap.get(targetNode);
    // ??
    slaveDataNodeInfo = (String[]) keyNodeMap.get(targetNode + "_sub");
    // ??
    thirdDataNodeInfo = (String[]) keyNodeMap.get(targetNode + "_third");

    // ????????
    if (thirdDataNodeInfo != null) {
        ret = new String[9];

        ret[3] = slaveDataNodeInfo[0];
        ret[4] = slaveDataNodeInfo[1];
        ret[5] = slaveDataNodeInfo[2];
        ret[6] = thirdDataNodeInfo[0];
        ret[7] = thirdDataNodeInfo[1];
        ret[8] = thirdDataNodeInfo[2];

    } else if (slaveDataNodeInfo != null) {
        // ????????
        ret = new String[6];

        ret[3] = slaveDataNodeInfo[0];
        ret[4] = slaveDataNodeInfo[1];
        ret[5] = slaveDataNodeInfo[2];
    } else {
        ret = new String[3];
    }

    ret[0] = mainDataNodeInfo[0];
    ret[1] = mainDataNodeInfo[1];
    ret[2] = mainDataNodeInfo[2];

    // ??????????(???)
    // ????????Wait
    while (true) {
        noWaitFlg = false;
        // ????
        if (ret.length == 3) {
            if (!StatusUtil.isWaitStatus(mainDataNodeInfo[2]))
                noWaitFlg = true;
        }

        if (ret.length == 6) {
            if (!StatusUtil.isWaitStatus(mainDataNodeInfo[2])
                    && !StatusUtil.isWaitStatus(slaveDataNodeInfo[2])) {

                noWaitFlg = true;
            }
        }

        if (ret.length == 9) {
            if (!StatusUtil.isWaitStatus(mainDataNodeInfo[2]) && !StatusUtil.isWaitStatus(slaveDataNodeInfo[2])
                    && !StatusUtil.isWaitStatus(thirdDataNodeInfo[2])) {

                noWaitFlg = true;
            }
        }

        if (noWaitFlg)
            break;

        try {
            //System.out.println("DataDispatcher - ?");
            Thread.sleep(50);
        } catch (Exception e) {
        }
    }

    // ??
    // ?MasterManagerHelper??
    StatusUtil.addNodeUse(mainDataNodeInfo[2]);

    if (ret.length > 3) {
        StatusUtil.addNodeUse(slaveDataNodeInfo[2]);
    }

    if (ret.length > 6) {
        StatusUtil.addNodeUse(thirdDataNodeInfo[2]);
    }

    return ret;
}