_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q154900
HtmlSerializerMiddlewares.htmlSerializeResponseSync
train
public static <T> Middleware<SyncHandler<Response<T>>, AsyncHandler<Response<ByteString>>> htmlSerializeResponseSync( final String templateName) { Middleware<SyncHandler<Response<T>>, AsyncHandler<Response<T>>> syncToAsync = Middleware::syncToAsync; return syncToAsync.and(htmlSerializeResponse(templateNam...
java
{ "resource": "" }
q154901
HttpService.boot
train
public static void boot(Service service, InstanceListener instanceListener, Thread.UncaughtExceptionHandler uncaughtExceptionHandler, String... args) throws LoadingException { Objects.requireNonNull(uncaughtExceptionHandler); Thread....
java
{ "resource": "" }
q154902
Middlewares.replyContentType
train
public static Middleware<AsyncHandler<?>, AsyncHandler<Response<?>>> replyContentType( String contentType) { return inner -> inner .map(Middlewares::ensureResponse) .map(response -> response.withHeader(CONTENT_TYPE, contentType)); }
java
{ "resource": "" }
q154903
Middlewares.serialize
train
public static Middleware<AsyncHandler<?>, AsyncHandler<Response<ByteString>>> serialize( Serializer serializer) { return inner -> inner .map(Middlewares::ensureResponse) .flatMapSync(resp -> ctx -> serializePayload(serializer, ctx.request(), resp)); }
java
{ "resource": "" }
q154904
EnvironmentFactoryBuilder.withConfigResolver
train
public EnvironmentFactoryBuilder withConfigResolver(EnvironmentConfigResolver configResolver) { checkState(!this.configResolver.isPresent(), "Configuration resolution already set"); return new EnvironmentFactoryBuilder(backendDomain, client, closer, resolver, Optional.o...
java
{ "resource": "" }
q154905
EnvironmentFactoryBuilder.withStaticConfig
train
public EnvironmentFactoryBuilder withStaticConfig(Config configNode) { checkState(!this.configResolver.isPresent(), "Configuration resolution already set"); return new EnvironmentFactoryBuilder(backendDomain, client, closer, resolver, Optional.of(new StaticConfigResolve...
java
{ "resource": "" }
q154906
EnvironmentFactoryBuilder.withClassLoader
train
public EnvironmentFactoryBuilder withClassLoader(ClassLoader classLoader) { checkState(!this.configResolver.isPresent(), "Configuration resolution already set"); return new EnvironmentFactoryBuilder(backendDomain, client, closer, resolver, Optional.of(new LazyConfigReso...
java
{ "resource": "" }
q154907
EndpointInvocationHandler.handle
train
void handle(OngoingRequest ongoingRequest, RequestContext requestContext, Endpoint endpoint) { try { endpoint.invoke(requestContext) .whenComplete((message, throwable) -> { try { if (message != null) { ongoingRequest.reply(message); } else if (...
java
{ "resource": "" }
q154908
SemanticServiceMetrics.requestDurationThresholdTracker
train
private Optional<DurationThresholdTracker> requestDurationThresholdTracker(MetricId id, String endpoint) { return durationThresholdConfig.getDurationThresholdForEndpoint(endpoint) .map(threshold -> Optional.of(new DurationThreshold...
java
{ "resource": "" }
q154909
RequestTracker.failRequests
train
private void failRequests() { final Set<OngoingRequest> requests = ImmutableSet.copyOf(outstanding); for (OngoingRequest id : requests) { final boolean removed = outstanding.remove(id); if (removed) { id.reply(Response.forStatus(Status.SERVICE_UNAVAILABLE)); } } }
java
{ "resource": "" }
q154910
CacheMapUtil.put
train
public static <T> Single<Boolean> put(CacheConfigBean cacheConfigBean, String key, String field, T value) { return SingleRxXian.call(CacheService.CACHE_SERVICE, "cacheMapPut", new JSONObject() {{ put("cacheConfig", cacheConfigBean); put("key", key); put("field", field); ...
java
{ "resource": "" }
q154911
CacheMapUtil.remove
train
public static Single<Boolean> remove(CacheConfigBean cacheConfigBean, String key, String field) { return SingleRxXian.call(CacheService.CACHE_SERVICE, "cacheMapRemove", new JSONObject() {{ put("cacheConfig", cacheConfigBean); put("key", key); put("field", field); }})....
java
{ "resource": "" }
q154912
CacheMapUtil.values
train
public static Maybe<List<String>> values(CacheConfigBean cacheConfigBean, String key) { return SingleRxXian .call(CacheService.CACHE_SERVICE, "cacheMapValues", new JSONObject() {{ put("cacheConfig", cacheConfigBean); put("key", key); }}) ...
java
{ "resource": "" }
q154913
CacheMapUtil.values
train
public static <T> Maybe<List<T>> values(String key, Class<T> vClazz) { return values(CacheService.CACHE_CONFIG_BEAN, key, vClazz); }
java
{ "resource": "" }
q154914
DistributedBarrier.setBarrier
train
public synchronized void setBarrier() throws Exception { try { client.create().creatingParentContainersIfNeeded().forPath(barrierPath); } catch ( KeeperException.NodeExistsException ignore ) { // ignore } }
java
{ "resource": "" }
q154915
DistributedBarrier.waitOnBarrier
train
public synchronized boolean waitOnBarrier(long maxWait, TimeUnit unit) throws Exception { long startMs = System.currentTimeMillis(); boolean hasMaxWait = (unit != null); long maxWaitMs = hasMaxWait ? TimeUnit.MILLISECONDS.convert(maxWait, unit) : Long.MAX_V...
java
{ "resource": "" }
q154916
ThreadPoolManager.newScheduledExecutor
train
public static ScheduledExecutorService newScheduledExecutor(int corePoolSize) { ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(corePoolSize); EXECUTORS.add(scheduledExecutorService); return scheduledExecutorService; }
java
{ "resource": "" }
q154917
CacheObjectUtil.luaScript
train
public static Object luaScript(String scripts, int keyCount, List<String> params) { return luaScript(CacheService.CACHE_CONFIG_BEAN, scripts, keyCount, params); }
java
{ "resource": "" }
q154918
CacheObjectUtil.luaScript
train
public static Single<Object> luaScript(CacheConfigBean cacheConfigBean, String scripts, int keyCount, List<String> params) { return SingleRxXian.call(CacheService.CACHE_SERVICE, "cacheLua", new JSONObject() {{ put("cacheConfig", cacheConfigBean); put("scripts", scripts); put(...
java
{ "resource": "" }
q154919
CacheObjectUtil.keys
train
@SuppressWarnings("unchecked") public static Single<Set<String>> keys(CacheConfigBean cacheConfigBean, String pattern) { return SingleRxXian.call(CacheService.CACHE_SERVICE, "cacheKeys", new JSONObject() {{ put("cacheConfig", cacheConfigBean); put("pattern", pattern); }}).map...
java
{ "resource": "" }
q154920
CacheObjectUtil.exists
train
public static Single<Boolean> exists(CacheConfigBean cacheConfigBean, String cacheKey) { return SingleRxXian.call(CacheService.CACHE_SERVICE, "cacheExists", new JSONObject() {{ put("cacheConfig", cacheConfigBean); put("key", cacheKey); }}).map(unitResponse -> { unitRe...
java
{ "resource": "" }
q154921
CacheObjectUtil.get
train
public static <T> Maybe<T> get(String cacheKey, Class<T> clazz) { return get(CacheService.CACHE_CONFIG_BEAN, cacheKey, clazz); }
java
{ "resource": "" }
q154922
CacheObjectUtil.remove
train
public static Single<Boolean> remove(CacheConfigBean cacheConfigBean, String cacheKey) { return SingleRxXian.call(CacheService.CACHE_SERVICE, "cacheObjectRemove", new JSONObject() {{ put("cacheConfig", cacheConfigBean); put("key", cacheKey); }}).map(unitResponseObject -> { ...
java
{ "resource": "" }
q154923
CacheObjectUtil.increment
train
public static Single<Long> increment(CacheConfigBean cacheConfigBean, String cacheKey) { return SingleRxXian.call(CacheService.CACHE_SERVICE, "cacheIncrement", new JSONObject() {{ put("cacheConfig", cacheConfigBean); put("key", cacheKey); }}).map(unitResponse -> { uni...
java
{ "resource": "" }
q154924
CacheObjectUtil.incrementByValue
train
public static Single<Long> incrementByValue(String cacheKey, long value) { return incrementByValue(CacheService.CACHE_CONFIG_BEAN, cacheKey, value); }
java
{ "resource": "" }
q154925
StackTraceFilter.getFilteredStackTrace
train
@Deprecated public static String getFilteredStackTrace(Throwable t, boolean shouldFilter) { if (shouldFilter) { return getFilteredStackTrace(t, 0); } StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); t.printStackTrace(pw); pw.cl...
java
{ "resource": "" }
q154926
StackTraceFilter.tryGetForbiddenPackageName
train
private static String tryGetForbiddenPackageName(String classAndMethod) { for (String pkg : suppressedPackages) { if (classAndMethod.startsWith(pkg)) { return pkg; } } return null; }
java
{ "resource": "" }
q154927
BaseDeleteDB.fmtObjectToStrArray
train
private static String[] fmtObjectToStrArray(Object object) { if (object == null) { return null; } if (object instanceof String[]) { return (String[]) object; } if (object instanceof Collection) { Collection c = (Collection) object; ...
java
{ "resource": "" }
q154928
GroupJudge.defined
train
public static boolean defined(String group) { return LocalUnitsManager.getGroupByName(group) != null || (GroupDiscovery.singleton != null && GroupDiscovery.singleton.newestDefinition(group) != null); }
java
{ "resource": "" }
q154929
GroupJudge.isDao
train
public static boolean isDao(String groupName) { try { return GroupRouter.singleton.newestDefinition(groupName).isDao(); } catch (GroupUndefinedException e) { throw new RuntimeException("Call GroupJudge.defined() first.", e); } }
java
{ "resource": "" }
q154930
UnitMeta.appendDescription
train
public UnitMeta appendDescription(String descriptionToBeAppended) { if (getDescription() != null) { setDescription(getDescription().concat(descriptionToBeAppended)); } else { setDescription(descriptionToBeAppended); } return this; }
java
{ "resource": "" }
q154931
DistributedAtomicValue.forceSet
train
public void forceSet(byte[] newValue) throws Exception { try { client.setData().forPath(path, newValue); } catch ( KeeperException.NoNodeException dummy ) { try { client.create().creatingParentContainersIfNeeded().forPath(pa...
java
{ "resource": "" }
q154932
TransactionFactory.getTransaction
train
public static Single<XianTransaction> getTransaction(String transactionId, boolean readOnly) { if (BaseLocalTransaction.getExistedLocalTrans(transactionId) != null) { return Single.just(BaseLocalTransaction.getExistedLocalTrans(transactionId)); } if (readOnly) { return Po...
java
{ "resource": "" }
q154933
RemoteSender.sendToRemote
train
private void sendToRemote(String nodeId) { unitRequest.getContext().setDestinationNodeId(nodeId); /*unitRequest.getContext().setSourceNodeId(LocalNodeManager.LOCAL_NODE_ID); let the node instance to fill this source node id property*/ LocalNodeManager.sendLoadBalanced(unitRequest, callback); ...
java
{ "resource": "" }
q154934
PathChildrenCache.getCurrentData
train
public List<ChildData> getCurrentData() { return ImmutableList.copyOf(Sets.<ChildData>newTreeSet(currentData.values())); }
java
{ "resource": "" }
q154935
ValidateAccessToken.fetchAccessTokenAndReturnScope
train
private static Single<Optional<String>> fetchAccessTokenAndReturnScope(UnitRequest request) { LOG.info("fetchAccessTokenAndReturnScope"); String ip = request.getContext().getIp(); if (StringUtil.isEmpty(ip)) { throw new IllegalArgumentException("Client's ip is empty, please check!");...
java
{ "resource": "" }
q154936
StringUtil.underlineToCamel
train
public static String underlineToCamel(String param) { if (isEmpty(param.trim())) { return ""; } StringBuilder sb = new StringBuilder(param); Matcher mc = Pattern.compile(UNDERLINE).matcher(param); int i = 0; while (mc.find()) { int position = mc.en...
java
{ "resource": "" }
q154937
StringUtil.camelToUnderline
train
public static Map<String, Object> camelToUnderline(Map<String, Object> map) { Map<String, Object> newMap = new HashMap<>(); for (String key : map.keySet()) { newMap.put(camelToUnderline(key), map.get(key)); } return newMap; }
java
{ "resource": "" }
q154938
StringUtil.getExceptionStacktrace
train
public static String getExceptionStacktrace(Throwable t) { try (StringWriter errors = new StringWriter()) { t.printStackTrace(new PrintWriter(errors)); return errors.toString(); } catch (IOException e) { LOG.error(e); return null; } }
java
{ "resource": "" }
q154939
StringUtil.split
train
public static String[] split(String str, String theSplitter) { if (StringUtil.isEmpty(str)) { return new String[0]; } return str.trim().split("\\s*" + escapeSpecialChar(theSplitter) + "\\s*"); }
java
{ "resource": "" }
q154940
UnitResponse.createSuccess
train
public static UnitResponse createSuccess(Object data, String errMsg) { return createSuccess(data).setMessage(errMsg); }
java
{ "resource": "" }
q154941
UnitResponse.createException
train
public static UnitResponse createException(String errCode, Throwable exception) { return UnitResponse.createException(exception).setCode(errCode); }
java
{ "resource": "" }
q154942
UnitResponse.createError
train
public static UnitResponse createError(String errCode, Object data, String errMsg) { if (Group.CODE_SUCCESS.equalsIgnoreCase(errCode)) { throw new IllegalArgumentException("Only non-success code is allowed here."); } return new UnitResponse().setCode(errCode).setData(data).setMessage...
java
{ "resource": "" }
q154943
UnitResponse.createTimeout
train
public static UnitResponse createTimeout(Object dataOrException, String errMsg) { return new UnitResponse().setCode(Group.CODE_TIME_OUT).setData(dataOrException).setMessage(errMsg); }
java
{ "resource": "" }
q154944
UnitResponse.createRollingBack
train
@SuppressWarnings("all") public static UnitResponse createRollingBack(String errMsg) { return UnitResponse.createUnknownError(null, errMsg).setContext(Context.create().setRollback(true)); }
java
{ "resource": "" }
q154945
UnitResponse.createMissingParam
train
public static UnitResponse createMissingParam(Object theMissingParameters, String errMsg) { return UnitResponse.createError(Group.CODE_LACK_OF_PARAMETER, theMissingParameters, errMsg); }
java
{ "resource": "" }
q154946
UnitResponse.toJSONString
train
public String toJSONString() { if (context.isPretty()) { return JSON.toJSONStringWithDateFormat(this, Constant.DATE_SERIALIZE_FORMAT, SerializerFeature.PrettyFormat); } else { return JSONObject.toJSONStringWithDateFormat(this, Constant.DATE_SERIALIZE_FORMAT); } }
java
{ "resource": "" }
q154947
UnitResponse.toVoJSONString
train
public String toVoJSONString(boolean pretty) { if (pretty) { return JSON.toJSONStringWithDateFormat(toVoJSONObject(), Constant.DATE_SERIALIZE_FORMAT, SerializerFeature.PrettyFormat); } else { return JSONObject.toJSONStringWithDateFormat(toVoJSONObject(), Constant.DATE_SERIALIZE_F...
java
{ "resource": "" }
q154948
UnitResponse.toJSONObject
train
@SuppressWarnings("all") public JSONObject toJSONObject() { try { return Reflection.toType(this, JSONObject.class); } catch (Throwable e) { throw new RuntimeException("The output cannot be converted to jsonObject!", e); } }
java
{ "resource": "" }
q154949
UnitResponse.processStreamPartByPart
train
public void processStreamPartByPart(String delimiterPattern, Function<String, Object> function) { StreamUtil.partByPart(dataToType(InputStream.class), delimiterPattern, function); }
java
{ "resource": "" }
q154950
UnitResponse.copy
train
public static void copy(UnitResponse from, UnitResponse to) { //remember to modify this method when new properties are added. to.setCode(from.code).setData(from.data).setContext(from.context.clone()).setMessage(from.message); }
java
{ "resource": "" }
q154951
UnitResponse.value
train
public Object value(int i, String key) { Object data = getData(); if (data instanceof List) { List list = (List) data; if (list.size() > 0) { Map map = (Map) list.get(i); return map.get(key); } } else if (data instanceof Map) { ...
java
{ "resource": "" }
q154952
AbstractLocalAsyncSender.fillResponseContext
train
private void fillResponseContext(UnitResponse.Context context) { context.setDestinationNodeId(unitRequest.getContext().getSourceNodeId()); context.setSourceNodeId(LocalNodeManager.LOCAL_NODE_ID); context.setMsgId(unitRequest.getContext().getMsgId()); context.setSsid(unitRequest.getContex...
java
{ "resource": "" }
q154953
GelfLog4j2Init.addAppender
train
private void addAppender() { final LoggerContext context = LoggerContext.getContext(false); final Configuration defaultConfig = context.getConfiguration(); String gelfInputUrl = EnvUtil.isLan() ? XianConfig.get("gelfInputLanUrl") : XianConfig.get("gelfInputInternetUrl"); System.out.print...
java
{ "resource": "" }
q154954
SharedValue.setValue
train
public void setValue(byte[] newValue) throws Exception { Preconditions.checkState(state.get() == State.STARTED, "not started"); Stat result = client.setData().forPath(path, newValue); updateValue(result.getVersion(), Arrays.copyOf(newValue, newValue.length)); }
java
{ "resource": "" }
q154955
SenderFuture.get
train
public UnitResponse get() { synchronized (responseLock) { while (!isDone()) try { responseLock.wait(); } catch (InterruptedException e) { throw new RuntimeException(e); } return unitResponse; ...
java
{ "resource": "" }
q154956
ServiceInstanceBuilder.build
train
public ServiceInstance<T> build() { return new ServiceInstance<T>(name, id, address, port, sslPort, payload, registrationTimeUTC, serviceType, uriSpec, enabled); }
java
{ "resource": "" }
q154957
CloseableScheduledExecutorService.scheduleWithFixedDelay
train
public Future<?> scheduleWithFixedDelay(Runnable task, long initialDelay, long delay, TimeUnit unit) { Preconditions.checkState(isOpen.get(), "CloseableExecutorService is closed"); ScheduledFuture<?> scheduledFuture = scheduledExecutorService.scheduleWithFixedDelay(task, initialDelay, delay, unit);...
java
{ "resource": "" }
q154958
JsonWriter.writeMapEntry
train
public static void writeMapEntry(OutputAccessor out, String key, Object value) { out.write((byte) '\"'); if (key == null) out.write(NULL); else { writeUtf8(out, key); } out.write(Q_AND_C); toJSONString(out, value); }
java
{ "resource": "" }
q154959
JsonWriter.toJSONString
train
private static void toJSONString(OutputAccessor out, Object value) { if (value == null) { out.write(NULL); return; } if (value instanceof String) { out.write((byte) '\"'); writeUtf8(out, (String) value); out.write((byte) '\"'); ...
java
{ "resource": "" }
q154960
JsonWriter.writeAscii
train
private static void writeAscii(OutputAccessor out, CharSequence seq) { // We can use the _set methods as these not need to do any index checks and reference checks. // This is possible as we called ensureWritable(...) before. for (int i = 0; i < seq.length(); i++) { out.write((byte)...
java
{ "resource": "" }
q154961
JsonWriter.writeUtf8
train
private static void writeUtf8(OutputAccessor out, CharSequence seq, int len) { // We can use the _set methods as these not need to do any index checks and reference checks. // This is possible as we called ensureWritable(...) before. for (int i = 0; i < len; i++) { char c = seq.char...
java
{ "resource": "" }
q154962
JsonWriter.escape
train
private static void escape(OutputAccessor out, int charToEscape) { out.write('\\'); out.write('u'); if (charToEscape > 0xFF) { int hi = (charToEscape >> 8) & 0xFF; out.write(HEX_BYTES[hi >> 4]); out.write(HEX_BYTES[hi & 0xF]); charToEscape &= 0xFF...
java
{ "resource": "" }
q154963
ConfigurationSupport.setMdcFields
train
public static void setMdcFields(String spec, GelfMessageAssembler gelfMessageAssembler) { if (null != spec) { String[] fields = spec.split(MULTI_VALUE_DELIMITTER); for (String field : fields) { gelfMessageAssembler.addField(new MdcMessageField(field.trim(), field.trim())...
java
{ "resource": "" }
q154964
ConfigurationSupport.setDynamicMdcFields
train
public static void setDynamicMdcFields(String spec, GelfMessageAssembler gelfMessageAssembler) { if (null != spec) { String[] fields = spec.split(MULTI_VALUE_DELIMITTER); for (String field : fields) { gelfMessageAssembler.addField(new DynamicMdcMessageField(field.trim())...
java
{ "resource": "" }
q154965
ConfigurationSupport.setAdditionalFieldTypes
train
public static void setAdditionalFieldTypes(String spec, GelfMessageAssembler gelfMessageAssembler) { if (null != spec) { String[] properties = spec.split(MULTI_VALUE_DELIMITTER); for (String field : properties) { final int index = field.indexOf(EQ); if (-...
java
{ "resource": "" }
q154966
GroupMember.start
train
public void start() { pen.start(); try { cache.start(); } catch ( Exception e ) { ThreadUtils.checkInterrupted(e); Throwables.propagate(e); } }
java
{ "resource": "" }
q154967
GroupMember.setThisData
train
public void setThisData(byte[] data) { try { pen.setData(data); } catch ( Exception e ) { ThreadUtils.checkInterrupted(e); Throwables.propagate(e); } }
java
{ "resource": "" }
q154968
GroupMember.getCurrentMembers
train
public Map<String, byte[]> getCurrentMembers() { ImmutableMap.Builder<String, byte[]> builder = ImmutableMap.builder(); boolean thisIdAdded = false; for ( ChildData data : cache.getCurrentData() ) { String id = idFromPath(data.getPath()); thisIdAdded = thisIdA...
java
{ "resource": "" }
q154969
RuleControllerRouter.getRule
train
private static RuleController getRule(String baseUri, UnitRequest controllerRequest, TransactionalNotifyHandler handler) { if (ruleMap == null) { synchronized (LOCK_FOR_LAZY_INITIALIZATION) { if (ruleMap == null) { loadRules(); } } ...
java
{ "resource": "" }
q154970
CreateBuilderImpl.findNode
train
static String findNode(final List<String> children, final String path, final String protectedId) { final String protectedPrefix = getProtectedPrefix(protectedId); String foundNode = Iterables.find ( children, new Predicate<String>() { ...
java
{ "resource": "" }
q154971
Reaper.addPath
train
public void addPath(String path, Mode mode) { PathHolder pathHolder = new PathHolder(path, mode, 0); activePaths.put(path, pathHolder); schedule(pathHolder, reapingThresholdMs); }
java
{ "resource": "" }
q154972
LOG.error
train
public static void error(Object message) { if (level.ordinal() >= Level.ERROR.ordinal()) singleton.error(message, null, loggerName()); }
java
{ "resource": "" }
q154973
LOG.error
train
public static void error(Throwable t) { if (level.ordinal() >= Level.ERROR.ordinal()) singleton.error(null, t, loggerName()); }
java
{ "resource": "" }
q154974
LOG.error
train
public static void error(Object errMsg, Throwable t) { if (level.ordinal() >= Level.ERROR.ordinal()) singleton.error(errMsg, t, loggerName()); }
java
{ "resource": "" }
q154975
LOG.warn
train
public static void warn(Object warnMsg) { if (level.ordinal() >= Level.WARN.ordinal()) if (warnMsg instanceof Throwable) { singleton.warn(null, (Throwable) warnMsg, loggerName()); } else { singleton.warn(warnMsg, null, loggerName()); } }
java
{ "resource": "" }
q154976
LOG.warn
train
public static void warn(Object warnMsg, Throwable t) { if (level.ordinal() >= Level.WARN.ordinal()) singleton.warn(warnMsg, t, loggerName()); }
java
{ "resource": "" }
q154977
LOG.cost
train
public static void cost(String type, long costInMilli) { info(new JSONObject() {{ put("type", type); put("cost", costInMilli); }}); }
java
{ "resource": "" }
q154978
LOG.getCallerFromTheCurrentStack
train
private static String getCallerFromTheCurrentStack() { StackTraceElement[] stes = new Throwable().getStackTrace(); for (StackTraceElement ste : stes) { String stackLine = ste.toString(); if (!stackLine.contains(LOG.class.getName())) { return stackLine; ...
java
{ "resource": "" }
q154979
InterProcessSemaphore.returnAll
train
public void returnAll(Collection<Lease> leases) { for ( Lease l : leases ) { CloseableUtils.closeQuietly(l); } }
java
{ "resource": "" }
q154980
TimeTrace.commit
train
public void commit() { long elapsed = System.nanoTime() - startTimeNanos; driver.addTrace(name, elapsed, TimeUnit.NANOSECONDS); }
java
{ "resource": "" }
q154981
CacheSystemUtil.jedisPoolAdd
train
public static Completable jedisPoolAdd(CacheConfigBean cacheConfigBean) { return SingleRxXian.call(CacheService.CACHE_SERVICE, "jedisPoolAdd", new JSONObject() {{ put("host", cacheConfigBean.getHost()); put("port", cacheConfigBean.getPort()); put("password", cacheConfigBean.g...
java
{ "resource": "" }
q154982
JsonInputValidatorFactory.getValidator
train
public static JsonInputValidator getValidator(Class<?> clazz) { if (clazz.equals(Scope.class)) { return ScopeValidator.getInstance(); } if (clazz.equals(ApplicationInfo.class)) { return ApplicationInfoValidator.getInstance(); } return null; }
java
{ "resource": "" }
q154983
QueueSharder.start
train
public void start() throws Exception { Preconditions.checkState(state.compareAndSet(State.LATENT, State.STARTED), "Cannot be started more than once"); client.createContainers(queuePath); getInitialQueues(); leaderLatch.start(); service.submit ( new Call...
java
{ "resource": "" }
q154984
QueueSharder.getQueue
train
public T getQueue() { Preconditions.checkState(state.get() == State.STARTED, "Not started"); List<String> localPreferredQueues = Lists.newArrayList(preferredQueues); if ( localPreferredQueues.size() > 0 ) { String key = localPreferredQueues.get(random.nextInt(...
java
{ "resource": "" }
q154985
RetryLoop.shouldRetry
train
public static boolean shouldRetry(int rc) { return (rc == KeeperException.Code.CONNECTIONLOSS.intValue()) || (rc == KeeperException.Code.OPERATIONTIMEOUT.intValue()) || (rc == KeeperException.Code.SESSIONMOVED.intValue()) || (rc == KeeperException.Code.SESSIONEXPIRED...
java
{ "resource": "" }
q154986
RetryLoop.isRetryException
train
public static boolean isRetryException(Throwable exception) { if ( exception instanceof KeeperException ) { KeeperException keeperException = (KeeperException)exception; return shouldRetry(keeperException.code().intValue()); } return false; }
java
{ "resource": "" }
q154987
ServiceCacheBuilderImpl.build
train
@Override public ServiceCache<T> build() { if (executorService != null) { return new ServiceCacheImplExt<>(discovery, name, executorService); } else { return new ServiceCacheImplExt<>(discovery, name, threadFactory); } }
java
{ "resource": "" }
q154988
ServiceCacheBuilderImpl.threadFactory
train
@Override public ServiceCacheBuilder<T> threadFactory(ThreadFactory threadFactory) { this.threadFactory = threadFactory; this.executorService = null; return this; }
java
{ "resource": "" }
q154989
ServiceCacheBuilderImpl.executorService
train
@Override public ServiceCacheBuilder<T> executorService(ExecutorService executorService) { this.executorService = new CloseableExecutorService(executorService); this.threadFactory = null; return this; }
java
{ "resource": "" }
q154990
DaoUnit.isTransactional
train
private boolean isTransactional(SqlAction[] sqlActions, XianTransaction transaction) { int count = 0; for (SqlAction sqlAction : sqlActions) { if (!(sqlAction instanceof ISelect)) { count++; } } return count > 1 || transaction.isBegun(); }
java
{ "resource": "" }
q154991
NodeCache.getListenable
train
public ListenerContainer<NodeCacheListener> getListenable() { Preconditions.checkState(state.get() != State.CLOSED, "Closed"); return listeners; }
java
{ "resource": "" }
q154992
ZKPaths.split
train
public static List<String> split(String path) { PathUtils.validatePath(path); return PATH_SPLITTER.splitToList(path); }
java
{ "resource": "" }
q154993
ZKPaths.deleteChildren
train
public static void deleteChildren(ZooKeeper zookeeper, String path, boolean deleteSelf) throws InterruptedException, KeeperException { PathUtils.validatePath(path); List<String> children = zookeeper.getChildren(path, null); for ( String child : children ) { String fullPa...
java
{ "resource": "" }
q154994
ZKPaths.getSortedChildren
train
public static List<String> getSortedChildren(ZooKeeper zookeeper, String path) throws InterruptedException, KeeperException { List<String> children = zookeeper.getChildren(path, false); List<String> sortedList = Lists.newArrayList(children); Collections.sort(sortedList); return sorte...
java
{ "resource": "" }
q154995
ZKPaths.makePath
train
public static String makePath(String parent, String child) { StringBuilder path = new StringBuilder(); joinPath(path, parent, child); return path.toString(); }
java
{ "resource": "" }
q154996
ZKPaths.makePath
train
public static String makePath(String parent, String firstChild, String... restChildren) { StringBuilder path = new StringBuilder(); joinPath(path, parent, firstChild); if ( restChildren == null ) { return path.toString(); } else { for...
java
{ "resource": "" }
q154997
RuntimeContainer.lookupHostname
train
public static void lookupHostname(ErrorReporter errorReporter) { String myHostName = getProperty(PROPERTY_LOGSTASH_GELF_HOSTNAME, "unknown"); String myFQDNHostName = getProperty(PROPERTY_LOGSTASH_GELF_FQDN_HOSTNAME, "unknown"); String myAddress = ""; if (!Boolean.parseBoolean(getPropert...
java
{ "resource": "" }
q154998
ScopeService.registerScope
train
public String registerScope(FullHttpRequest req) throws OAuthException { String contentType = (req.headers() != null) ? req.headers().get(HttpHeaderNames.CONTENT_TYPE) : null; // check Content-Type if (contentType != null && contentType.contains(ResponseBuilder.APPLICATION_JSON)) { t...
java
{ "resource": "" }
q154999
ScopeService.getScopes
train
public String getScopes(HttpRequest req) throws OAuthException { QueryStringDecoder dec = new QueryStringDecoder(req.uri()); Map<String, List<String>> queryParams = dec.parameters(); if (queryParams.containsKey("client_id")) { return getScopes(queryParams.get("client_id").get(0)); ...
java
{ "resource": "" }