/** * Sets the publisher ID used for identifying the publisher in a * {@link WanReplicationConfig}. * If there is no publisher ID defined (it is empty), the group name will * be used as a publisher ID. * * @param publisherId the WAN publisher ID * @return this config * @see #getGroupName() */ public WanPublisherConfig setPublisherId(String publisherId) { this.publisherId = !isNullOrEmptyAfterTrim(publisherId) ? publisherId : null; return this; }
private static String classNameOrClass(String className, Class clazz) { return !isNullOrEmpty(className) ? className : clazz != null ? clazz.getName() : null; }
public String toString() { return "MemcacheEntry{" + "bytes=" + bytesToString(bytes) + ", flag=" + flag + '}'; }
/** * Create instance from String * * @param string * @return instance of {@link CacheDeserializedValues} * @throws IllegalArgumentException when unknown value is passed */ public static CacheDeserializedValues parseString(String string) { String upperCase = StringUtil.upperCaseInternal(string); if ("NEVER".equals(upperCase)) { return NEVER; } else if ("INDEX_ONLY".equals(upperCase) || "INDEX-ONLY".equals(upperCase)) { return INDEX_ONLY; } else if ("ALWAYS".equals(upperCase)) { return ALWAYS; } else { throw new IllegalArgumentException("Unknown CacheDeserializedValues option '" + string + "'. " + "Possible options: " + Arrays.toString(CacheDeserializedValues.values())); } } }
private void handleChangeClusterState(HttpPostCommand command) throws UnsupportedEncodingException { byte[] data = command.getData(); String[] strList = bytesToString(data).split("&"); String res; try { Node node = textCommandService.getNode(); ClusterService clusterService = node.getClusterService(); if (authenticate(command, strList[0], strList.length > 1 ? strList[1] : null)) { String stateParam = URLDecoder.decode(strList[2], "UTF-8"); ClusterState state = ClusterState.valueOf(upperCaseInternal(stateParam)); if (!state.equals(clusterService.getClusterState())) { clusterService.changeClusterState(state); res = response(ResponseType.SUCCESS, "state", state.toString().toLowerCase(StringUtil.LOCALE_INTERNAL)); } else { res = response(ResponseType.FAIL, "state", state.toString().toLowerCase(StringUtil.LOCALE_INTERNAL)); } } else { res = response(ResponseType.FORBIDDEN); } } catch (Throwable throwable) { logger.warning("Error occurred while changing cluster state", throwable); res = exceptionResponse(throwable); } command.setResponse(HttpCommand.CONTENT_TYPE_JSON, stringToBytes(res)); }
boolean advanceToNextToken() { if (nextSplit == -1) { return false; } token = null; int oldNextSplit = nextSplit; nextSplit = StringUtil.indexOf(path, '.', oldNextSplit + 1); offset = oldNextSplit + 1; index++; return true; }
command = trim(command); if (command.length() == 0) { return; String[] args = new String[argsSplit.length]; for (int i = 0; i < argsSplit.length; i++) { args[i] = trim(argsSplit[i]); } else if ("silent".equals(first)) { silent = Boolean.parseBoolean(args[1]); } else if (equalsIgnoreCase("shutdown", first)) { handleShutdown(); } else if ("echo".equals(first)) { println("echo: " + echo); } else if ("ns".equals(first)) { handleNamespace(trim(command.substring(first.length()))); } else if ("whoami".equals(first)) { handleWhoami(); } else if (first.equals("m.replace")) { handleMapReplace(args); } else if (equalsIgnoreCase(first, "m.putIfAbsent")) { handleMapPutIfAbsent(args); } else if (first.equals("m.putAsync")) { } else if (first.equals("m.get")) { handleMapGet(args); } else if (equalsIgnoreCase(first, "m.getMapEntry")) {
/** * Like a String.lastIndexOf but without MIN_SUPPLEMENTARY_CODE_POINT handling * * @param input to check the indexOf on * @param ch character to find the index of * @return index of the character, or -1 if not found */ public static int lastIndexOf(String input, char ch) { return lastIndexOf(input, ch, 0); }
private String getProbeOrMethodName() { return probe.name().length() != 0 ? probe.name() : getterIntoProperty(method.getName()); }
@SuppressWarnings({"LockAcquiredButNotSafelyReleased", "squid:S2222"}) protected void handleLock(String[] args) { String lockStr = args[0]; String key = args[1]; Lock lock = hazelcast.getLock(key); if (equalsIgnoreCase(lockStr, "lock")) { lock.lock(); println("true"); } else if (equalsIgnoreCase(lockStr, "unlock")) { lock.unlock(); println("true"); } else if (equalsIgnoreCase(lockStr, "trylock")) { String timeout = args.length > 2 ? args[2] : null; if (timeout == null) { println(lock.tryLock()); } else { long time = Long.parseLong(timeout); try { println(lock.tryLock(time, TimeUnit.SECONDS)); } catch (InterruptedException e) { currentThread().interrupt(); e.printStackTrace(); } } } }
/** * Create instance from String * * @param string * @return instance of {@link CacheDeserializedValues} * @throws IllegalArgumentException when unknown value is passed */ public static CacheDeserializedValues parseString(String string) { String upperCase = StringUtil.upperCaseInternal(string); if ("NEVER".equals(upperCase)) { return NEVER; } else if ("INDEX_ONLY".equals(upperCase) || "INDEX-ONLY".equals(upperCase)) { return INDEX_ONLY; } else if ("ALWAYS".equals(upperCase)) { return ALWAYS; } else { throw new IllegalArgumentException("Unknown CacheDeserializedValues option '" + string + "'. " + "Possible options: " + Arrays.toString(CacheDeserializedValues.values())); } } }
/** * Like a String.indexOf but without MIN_SUPPLEMENTARY_CODE_POINT handling * * @param input to check the indexOf on * @param ch character to find the index of * @return index of the character, or -1 if not found */ public static int indexOf(String input, char ch) { return indexOf(input, ch, 0); }
command = trim(command); if (command.length() == 0) { return; String[] args = new String[argsSplit.length]; for (int i = 0; i < argsSplit.length; i++) { args[i] = trim(argsSplit[i]); } else if ("silent".equals(first)) { silent = Boolean.parseBoolean(args[1]); } else if (equalsIgnoreCase("shutdown", first)) { handleShutdown(); } else if ("echo".equals(first)) { println("echo: " + echo); } else if ("ns".equals(first)) { handleNamespace(trim(command.substring(first.length()))); } else if ("whoami".equals(first)) { handleWhoami(); } else if (first.equals("m.replace")) { handleMapReplace(args); } else if (equalsIgnoreCase(first, "m.putIfAbsent")) { handleMapPutIfAbsent(args); } else if (first.equals("m.putAsync")) { } else if (first.equals("m.get")) { handleMapGet(args); } else if (equalsIgnoreCase(first, "m.getMapEntry")) {
/** * Like a String.lastIndexOf but without MIN_SUPPLEMENTARY_CODE_POINT handling * * @param input to check the indexOf on * @param ch character to find the index of * @return index of the character, or -1 if not found */ public static int lastIndexOf(String input, char ch) { return lastIndexOf(input, ch, 0); }
private String getProbeOrMethodName() { return probe.name().length() != 0 ? probe.name() : getterIntoProperty(method.getName()); }
@SuppressWarnings({"LockAcquiredButNotSafelyReleased", "squid:S2222"}) protected void handleLock(String[] args) { String lockStr = args[0]; String key = args[1]; Lock lock = hazelcast.getLock(key); if (equalsIgnoreCase(lockStr, "lock")) { lock.lock(); println("true"); } else if (equalsIgnoreCase(lockStr, "unlock")) { lock.unlock(); println("true"); } else if (equalsIgnoreCase(lockStr, "trylock")) { String timeout = args.length > 2 ? args[2] : null; if (timeout == null) { println(lock.tryLock()); } else { long time = Long.parseLong(timeout); try { println(lock.tryLock(time, TimeUnit.SECONDS)); } catch (InterruptedException e) { currentThread().interrupt(); e.printStackTrace(); } } } }
/** * Sets the publisher ID used for identifying the publisher in a * {@link WanReplicationConfig}. * If there is no publisher ID defined (it is empty), the group name will * be used as a publisher ID. * * @param publisherId the WAN publisher ID * @return this config * @see #getGroupName() */ public WanPublisherConfig setPublisherId(String publisherId) { this.publisherId = !isNullOrEmptyAfterTrim(publisherId) ? publisherId : null; return this; }
private static String classNameOrImplClass(String className, Object impl) { return !isNullOrEmpty(className) ? className : impl != null ? impl.getClass().getName() : null; } }
private EvictionConfig getEvictionConfig(Node node) { EvictionConfig evictionConfig = new EvictionConfig(); Node size = node.getAttributes().getNamedItem("size"); Node maxSizePolicy = node.getAttributes().getNamedItem("max-size-policy"); Node evictionPolicy = node.getAttributes().getNamedItem("eviction-policy"); if (size != null) { evictionConfig.setSize(Integer.parseInt(getTextContent(size))); } if (maxSizePolicy != null) { evictionConfig .setMaximumSizePolicy(EvictionConfig.MaxSizePolicy.valueOf(upperCaseInternal(getTextContent(maxSizePolicy))) ); } if (evictionPolicy != null) { evictionConfig.setEvictionPolicy(EvictionPolicy.valueOf(upperCaseInternal(getTextContent(evictionPolicy))) ); } return evictionConfig; }
public String toString() { return "MemcacheEntry{" + "bytes=" + bytesToString(bytes) + ", flag=" + flag + '}'; }