_id stringlengths 2 7 | title stringlengths 3 140 | partition stringclasses 3
values | text stringlengths 73 34.1k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q155000 | ScopeService.getValidScope | train | public Maybe<String> getValidScope(String scope, String clientId) {
return DBManagerFactory.getInstance()
.findClientCredentials(clientId)
.map(creds -> getValidScopeByScope(scope, creds.getScope()));
} | java | {
"resource": ""
} |
q155001 | ScopeService.scopeAllowed | train | public boolean scopeAllowed(String scope, String allowedScopes) {
String[] allScopes = allowedScopes.split(SPACE);
List<String> allowedList = Arrays.asList(allScopes);
String[] scopes = scope.split(SPACE);
int allowedCount = 0;
for (String s : scopes) {
if (allowedLis... | java | {
"resource": ""
} |
q155002 | ScopeService.getExpiresIn | train | public int getExpiresIn(String tokenGrantType, String scope) {
int expiresIn = Integer.MAX_VALUE;
List<Scope> scopes = loadScopes(scope);
boolean ccGrantType = TokenRequest.CLIENT_CREDENTIALS.equals(tokenGrantType);
if (TokenRequest.CLIENT_CREDENTIALS.equals(tokenGrantType)) {
... | java | {
"resource": ""
} |
q155003 | ScopeService.updateScope | train | public String updateScope(FullHttpRequest req, String scopeName) 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))... | java | {
"resource": ""
} |
q155004 | ScopeService.deleteScope | train | public String deleteScope(String scopeName) throws OAuthException {
String responseMsg;
Scope foundScope = DBManagerFactory.getInstance().findScope(scopeName).blockingGet();
if (foundScope == null) {
LOG.error("scope does not exist");
throw new OAuthException(SCOPE_NOT_EX... | java | {
"resource": ""
} |
q155005 | TreeCache.handleException | train | private void handleException(final Throwable e)
{
if ( errorListeners.size() == 0 )
{
LOG.error("", e);
}
else
{
errorListeners.forEach(new Function<UnhandledErrorListener, Void>()
{
@Override
public Void app... | java | {
"resource": ""
} |
q155006 | CacheSetUtil.exists | train | public static Single<Boolean> exists(String key, Object member) {
return exists(CacheService.CACHE_CONFIG_BEAN, key, member);
} | java | {
"resource": ""
} |
q155007 | CacheSetUtil.addAll | train | public static Single<Long> addAll(CacheConfigBean cacheConfigBean, String key, Set members) {
return SingleRxXian.call(CacheService.CACHE_SERVICE, "cacheSetAdd", new JSONObject() {{
put("cacheConfig", cacheConfigBean);
put("key", key);
put("members", members);
}}).map... | java | {
"resource": ""
} |
q155008 | CacheSetUtil.removes | train | public static Single<Long> removes(String key, Set members) {
return removes(CacheService.CACHE_CONFIG_BEAN, key, members);
} | java | {
"resource": ""
} |
q155009 | CuratorZookeeperClient.start | train | public void start() throws Exception
{
log.debug("Starting");
if ( !started.compareAndSet(false, true) )
{
IllegalStateException ise = new IllegalStateException("Already started");
throw ise;
}
state.start();
} | java | {
"resource": ""
} |
q155010 | CuratorZookeeperClient.startAdvancedTracer | train | public OperationTrace startAdvancedTracer(String name)
{
return new OperationTrace(name, tracer.get(), state.getSessionId());
} | java | {
"resource": ""
} |
q155011 | ServiceDiscoveryImpl.start | train | @Override
public void start() throws Exception
{
try
{
reRegisterServices();
}
catch ( KeeperException e )
{
log.error("Could not register instances - will try again later", e);
}
client.getConnectionStateListenable().addListener(co... | java | {
"resource": ""
} |
q155012 | ServiceDiscoveryImpl.queryForNames | train | @Override
public List<String> queryForNames() throws Exception
{
List<String> names = client.getChildren().forPath(basePath);
return ImmutableList.copyOf(names);
} | java | {
"resource": ""
} |
q155013 | ServiceDiscoveryImpl.queryForInstances | train | @Override
public Collection<ServiceInstance<T>> queryForInstances(String name) throws Exception
{
return queryForInstances(name, null);
} | java | {
"resource": ""
} |
q155014 | ServiceDiscoveryImpl.queryForInstance | train | @Override
public ServiceInstance<T> queryForInstance(String name, String id) throws Exception
{
String path = pathForInstance(name, id);
try
{
byte[] bytes = client.getData().forPath(path);
return serializer.deserialize(bytes);
}
catch ( KeeperExce... | java | {
"resource": ""
} |
q155015 | MapFormat.processPattern | train | public String processPattern(String newPattern) throws IllegalArgumentException {
int idx = 0;
int offnum = -1;
StringBuffer outpat = new StringBuffer();
offsets = new int[BUFSIZE];
arguments = new String[BUFSIZE];
maxOffset = -1;
//skipped = new RangeList();
... | java | {
"resource": ""
} |
q155016 | MapFormat.formatObject | train | private String formatObject(Object obj) {
if (obj == null) {
return null;
}
if (obj instanceof Number) {
return NumberFormat.getInstance(locale).format(obj); // fix
} else if (obj instanceof Date) {
return DateFormat.getDateTimeInstance(DateFormat.SHO... | java | {
"resource": ""
} |
q155017 | MapFormat.format | train | public StringBuffer format(Object pat, StringBuffer result, FieldPosition fpos) {
String pattern = processPattern((String) pat);
int lastOffset = 0;
for (int i = 0; i <= maxOffset; ++i) {
int offidx = offsets[i];
result.append(pattern.substring(lastOffset, offsets[i]));
... | java | {
"resource": ""
} |
q155018 | BaseXianConnection.createLocalTransaction | train | private BaseLocalTransaction createLocalTransaction(String transId) {
BaseLocalTransaction baseLocalTransaction;
try {
baseLocalTransaction = localTransactionConstructor.newInstance(transId, this);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e... | java | {
"resource": ""
} |
q155019 | ArrayUtil.toList | train | public static <T> List<T> toList(Object array, Class<T> clazz) {
List<T> list = new ArrayList<>();
for (Object o : toObjectArray(array)) {
list.add(Reflection.toType(o, clazz));
}
return list;
} | java | {
"resource": ""
} |
q155020 | ArrayUtil.toArray | train | @SuppressWarnings("unchecked")
public static <T> T[] toArray(List list, Class<T> tClass) {
Object arrayObject = Array.newInstance(tClass, list.size());
for (int i = 0; i < list.size(); i++) {
Array.set(arrayObject, i, list.get(i));
}
return (T[]) arrayObject;
} | java | {
"resource": ""
} |
q155021 | ArrayUtil.concat | train | public static <T> T[] concat(T[] first, T[] second) {
T[] result = Arrays.copyOf(first, first.length + second.length);
System.arraycopy(second, 0, result, first.length, second.length);
return result;
} | java | {
"resource": ""
} |
q155022 | CacheListUtil.exists | train | public static Single<Boolean> exists(CacheConfigBean cacheConfigBean, String cacheKey) {
return SingleRxXian.call(CacheService.CACHE_SERVICE, "cacheListExists", new JSONObject() {{
put("cacheConfig", cacheConfigBean);
put("key", cacheKey);
}}).map(UnitResponse::dataToBoolean);
... | java | {
"resource": ""
} |
q155023 | CacheListUtil.length | train | public static Single<Long> length(CacheConfigBean cacheConfigBean, String cacheKey) {
return SingleRxXian.call(CacheService.CACHE_SERVICE, "cacheListLength", new JSONObject() {{
put("cacheConfig", cacheConfigBean);
put("key", cacheKey);
}}).map(unitResponse -> {
long ... | java | {
"resource": ""
} |
q155024 | CacheListUtil.isEmpty | train | public static Single<Boolean> isEmpty(CacheConfigBean cacheConfigBean, String cacheKey) {
return length(cacheConfigBean, cacheKey).map(length -> length == 0);
} | java | {
"resource": ""
} |
q155025 | CacheListUtil.addFirst | train | public static Single<Boolean> addFirst(String cacheKey, Object value) {
return addFirst(CacheService.CACHE_CONFIG_BEAN, cacheKey, value);
} | java | {
"resource": ""
} |
q155026 | CacheListUtil.remove | train | public static Single<Long> remove(String cacheKey, Object value) {
return remove(CacheService.CACHE_CONFIG_BEAN, cacheKey, value);
} | java | {
"resource": ""
} |
q155027 | CacheListUtil.clear | train | public static Completable clear(CacheConfigBean cacheConfigBean, String cacheKey) {
return SingleRxXian.call(CacheService.CACHE_SERVICE, "cacheListClear", new JSONObject() {{
put("cacheConfig", cacheConfigBean);
put("key", cacheKey);
}}).toCompletable();
} | java | {
"resource": ""
} |
q155028 | CacheListUtil.delete | train | public static Single<Boolean> delete(CacheConfigBean cacheConfigBean, String cacheKey) {
return CacheObjectUtil.remove(cacheConfigBean, cacheKey);
} | java | {
"resource": ""
} |
q155029 | CloseableExecutorService.close | train | @Override
public void close()
{
isOpen.set(false);
Iterator<Future<?>> iterator = futures.iterator();
while ( iterator.hasNext() )
{
Future<?> future = iterator.next();
iterator.remove();
if ( !future.isDone() && !future.isCancelled() && !futur... | java | {
"resource": ""
} |
q155030 | CloseableExecutorService.submit | train | public<V> Future<V> submit(Callable<V> task)
{
Preconditions.checkState(isOpen.get(), "CloseableExecutorService is closed");
InternalFutureTask<V> futureTask = new InternalFutureTask<V>(new FutureTask<V>(task));
executorService.execute(futureTask);
return futureTask;
} | java | {
"resource": ""
} |
q155031 | CloseableExecutorService.submit | train | public Future<?> submit(Runnable task)
{
Preconditions.checkState(isOpen.get(), "CloseableExecutorService is closed");
InternalFutureTask<Void> futureTask = new InternalFutureTask<Void>(new FutureTask<Void>(task, null));
executorService.execute(futureTask);
return futureTask;
} | java | {
"resource": ""
} |
q155032 | BusinessHandler.checkAndRespond | train | private boolean checkAndRespond(Request request) {
if (!URIBean.checkUri(request.getUrl())) {
ServerResponseBean responseBean = new ServerResponseBean();
responseBean.setMsgId(request.getMsgId());
responseBean.setHttpContentType(HttpContentType.APPLICATION_JSON);
... | java | {
"resource": ""
} |
q155033 | Authenticator.issueClientCredentials | train | public Single<ClientCredentials> issueClientCredentials(HttpRequest req) throws OAuthException {
Single<ClientCredentials> creds;
String contentType = req.headers().get(HttpHeaderNames.CONTENT_TYPE);
if (contentType != null && contentType.contains(HttpHeaderValues.APPLICATION_JSON)) {
... | java | {
"resource": ""
} |
q155034 | Authenticator.authenticateUser | train | protected UserDetails authenticateUser(String username, String password, HttpRequest authRequest) throws AuthenticationException {
UserDetails userDetails;
IUserAuthentication ua;
if (OAuthConfig.getUserAuthenticationClass() != null) {
try {
ua = OAuthConfig.getUserAu... | java | {
"resource": ""
} |
q155035 | Authenticator.getApplicationInfo | train | public Maybe<ApplicationInfo> getApplicationInfo(String clientId) {
return db.findClientCredentials(clientId).map(creds -> {
ApplicationInfo appInfo = null;
if (creds != null) {
appInfo = ApplicationInfo.loadFromClientCredentials(creds);
}
return a... | java | {
"resource": ""
} |
q155036 | Authenticator.isValidClientCredentials | train | protected Single<Boolean> isValidClientCredentials(String clientId, String clientSecret) {
return db.findClientCredentials(clientId)
.map(creds -> creds.getSecret().equals(clientSecret))
.switchIfEmpty(Single.just(false))
;
} | java | {
"resource": ""
} |
q155037 | Authenticator.blockingUpdateClientApp | train | public boolean blockingUpdateClientApp(HttpRequest req, String clientId) throws OAuthException {
String contentType = req.headers().get(HttpHeaderNames.CONTENT_TYPE);
if (contentType != null && contentType.contains(ResponseBuilder.APPLICATION_JSON)) {
// String LOCAL_NODE_ID = getBasicAuthori... | java | {
"resource": ""
} |
q155038 | GelfMessage.writeIfNotEmpty | train | private static boolean writeIfNotEmpty(OutputAccessor out, boolean hasFields, String field, Object value) {
if (value == null) {
return hasFields;
}
if (value instanceof String) {
if (GelfMessage.isEmpty((String) value)) {
return hasFields;
... | java | {
"resource": ""
} |
q155039 | GelfMessage.getAdditionalFieldValue | train | static Object getAdditionalFieldValue(String value, String fieldType) {
Object result = null;
if (fieldType.equalsIgnoreCase(FIELD_TYPE_DISCOVER)) {
Result discoveredType = ValueDiscovery.discover(value);
if (discoveredType == Result.STRING) {
return value;
... | java | {
"resource": ""
} |
q155040 | LockInternals.clean | train | public void clean() throws Exception
{
try
{
client.delete().forPath(basePath);
}
catch ( KeeperException.BadVersionException ignore )
{
// ignore - another thread/process got the lock
}
catch ( KeeperException.NotEmptyException ignore ... | java | {
"resource": ""
} |
q155041 | LeaderSelector.close | train | public synchronized void close()
{
Preconditions.checkState(state.compareAndSet(State.STARTED, State.CLOSED), "Already closed or has not been started");
client.getConnectionStateListenable().removeListener(listener);
executorService.close();
ourTask.set(null);
} | java | {
"resource": ""
} |
q155042 | LeaderSelector.interruptLeadership | train | public synchronized void interruptLeadership()
{
Future<?> task = ourTask.get();
if ( task != null )
{
task.cancel(true);
}
} | java | {
"resource": ""
} |
q155043 | LeaderSelector.wrapExecutor | train | private static ExecutorService wrapExecutor(final Executor executor)
{
return new AbstractExecutorService()
{
private volatile boolean isShutdown = false;
private volatile boolean isTerminated = false;
@Override
public void shutdown()
{
... | java | {
"resource": ""
} |
q155044 | ClassGraphUtil.getNonAbstractSubClasses | train | @SuppressWarnings("all")
synchronized public static <T> Set<Class<? extends T>> getNonAbstractSubClasses(Class<T> parentClass, String... packageNames) {
return getNonAbstractSubClassInfoSet(parentClass, packageNames).stream().map(classInfo -> {
try {
//Here we must use parentClas... | java | {
"resource": ""
} |
q155045 | ClassGraphUtil.getSubclassInstances | train | public synchronized static <T> Set<T> getSubclassInstances(Class<T> parentClass, String... packageNames) {
return getNonAbstractSubClasses(parentClass, packageNames).stream()
.filter(subclass -> {
if (Reflection.canInitiate(subclass)) {
return true;
... | java | {
"resource": ""
} |
q155046 | DistributedDoubleBarrier.enter | train | public boolean enter(long maxWait, TimeUnit unit) throws Exception
{
long startMs = System.currentTimeMillis();
boolean hasMaxWait = (unit != null);
long maxWaitMs = hasMaxWait ? TimeUnit.MILLISECONDS.convert(maxWait, unit) : Long.MAX_VALUE;
boolean... | java | {
"resource": ""
} |
q155047 | DistributedDoubleBarrier.leave | train | public synchronized boolean leave(long maxWait, TimeUnit unit) throws Exception
{
long startMs = System.currentTimeMillis();
boolean hasMaxWait = (unit != null);
long maxWaitMs = hasMaxWait ? TimeUnit.MILLISECONDS.convert(maxWait, unit) : Long.MAX_VALUE;
... | java | {
"resource": ""
} |
q155048 | ServiceDiscoveryBuilder.builder | train | public static <T> ServiceDiscoveryBuilder<T> builder(Class<T> payloadClass)
{
return new ServiceDiscoveryBuilder<T>(payloadClass);
} | java | {
"resource": ""
} |
q155049 | AfterConnectionEstablished.execute | train | public static Future<?> execute(final CuratorFramework client, final Runnable runAfterConnection) throws Exception
{
//Block until connected
final ExecutorService executor = ThreadUtils.newSingleThreadExecutor(ThreadUtils.getProcessName(runAfterConnection.getClass()));
Runnable internalCall ... | java | {
"resource": ""
} |
q155050 | SimpleDistributedQueue.element | train | public byte[] element() throws Exception
{
byte[] bytes = internalElement(false, null);
if ( bytes == null )
{
throw new NoSuchElementException();
}
return bytes;
} | java | {
"resource": ""
} |
q155051 | SimpleDistributedQueue.remove | train | public byte[] remove() throws Exception
{
byte[] bytes = internalElement(true, null);
if ( bytes == null )
{
throw new NoSuchElementException();
}
return bytes;
} | java | {
"resource": ""
} |
q155052 | SimpleDistributedQueue.offer | train | public boolean offer(byte[] data) throws Exception
{
String thisPath = ZKPaths.makePath(path, PREFIX);
client.create().creatingParentContainersIfNeeded().withMode(CreateMode.PERSISTENT_SEQUENTIAL).forPath(thisPath, data);
return true;
} | java | {
"resource": ""
} |
q155053 | JdbcSqlDriver.insert | train | private Single<SingleInsertionResult> insert(String preparedSql, Object[] sqlParams) {
return Single.fromCallable(() -> {
PreparedStatement statement = connection0.prepareStatement(preparedSql, PreparedStatement.RETURN_GENERATED_KEYS);
for (int i = 0; i < sqlParams.length; i++) {
... | java | {
"resource": ""
} |
q155054 | GelfConsoleAppender.setAdditionalFields | train | public void setAdditionalFields(String additionalFields) {
fields = (Map<String, String>) JSON.parse(additionalFields.replaceAll("'", "\""));
} | java | {
"resource": ""
} |
q155055 | GelfConsoleAppender.subAppend | train | @Override
protected void subAppend(LoggingEvent event) {
GelfMessage gelf = GelfMessageFactory.makeMessage(layout, event, this);
this.qw.write(gelf.toJson());
this.qw.write(Layout.LINE_SEP);
if (this.immediateFlush) {
this.qw.flush();
}
} | java | {
"resource": ""
} |
q155056 | Input.create | train | public static <Request> Input create(Request requestBean) {
if (requestBean == null)
throw new IllegalArgumentException("request bean should not be null!");
Class requestClass = requestBean.getClass();
return create(requestClass);
} | java | {
"resource": ""
} |
q155057 | QueueBuilder.builder | train | public static<T> QueueBuilder<T> builder(CuratorFramework client, QueueConsumer<T> consumer, QueueSerializer<T> serializer, String queuePath)
{
return new QueueBuilder<T>(client, consumer, serializer, queuePath);
} | java | {
"resource": ""
} |
q155058 | GelfBuffers.toUDPBuffers | train | protected static ByteBuffer[] toUDPBuffers(GelfMessage message, ThreadLocal<ByteBuffer> writeBuffers,
ThreadLocal<ByteBuffer> tempBuffers) {
while (true) {
try {
return message.toUDPBuffers(getBuffer(writeBuffers), getBuffer(tempBuffers));
} catch (BufferOve... | java | {
"resource": ""
} |
q155059 | GelfBuffers.toTCPBuffer | train | protected static ByteBuffer toTCPBuffer(GelfMessage message, ThreadLocal<ByteBuffer> writeBuffers) {
while (true) {
try {
return message.toTCPBuffer(getBuffer(writeBuffers));
} catch (BufferOverflowException e) {
enlargeBuffer(writeBuffers);
... | java | {
"resource": ""
} |
q155060 | Xmap.create | train | public static <K, V> Xmap<K, V> create(Map<K, V> map) {
Xmap<K, V> xmap = new Xmap<>();
xmap.putAll(map);
return xmap;
} | java | {
"resource": ""
} |
q155061 | CloudFile.exists | train | public static Single<Boolean> exists(String path) {
return SingleRxXian.call("cosService", "cosCheckFileExists", new JSONObject() {{
put("path", path);
}}).map(UnitResponse::dataToBoolean);
} | java | {
"resource": ""
} |
q155062 | LocalUnitsManager.replaceUnit | train | public static void replaceUnit(/*String group, String unitName, */ Unit newUnit) {
String group = newUnit.getGroup().getName(), unitName = newUnit.getName();
readWriteLock.writeLock().lock();
try {
//unitMap
List<Unit> unitList = unitMap.get(group);
unitList.r... | java | {
"resource": ""
} |
q155063 | LocalUnitsManager.getGroupByUnitClass | train | public static Group getGroupByUnitClass(Class<? extends Unit> unitClass) {
readWriteLock.readLock().lock();
try {
return searchGroupByUnitClass.get(unitClass);
} finally {
readWriteLock.readLock().unlock();
}
} | java | {
"resource": ""
} |
q155064 | LocalUnitsManager.getUnitByUnitClass | train | public static Unit getUnitByUnitClass(Class<? extends Unit> unitClass) {
readWriteLock.readLock().lock();
try {
return searchUnitByClass.get(unitClass);
} finally {
readWriteLock.readLock().unlock();
}
} | java | {
"resource": ""
} |
q155065 | EnsurePath.ensure | train | public void ensure(CuratorZookeeperClient client) throws Exception
{
Helper localHelper = helper.get();
localHelper.ensure(client, path, makeLastNode);
} | java | {
"resource": ""
} |
q155066 | RandomGenerator.generateDigitsString | train | public static String generateDigitsString(int length) {
StringBuffer buf = new StringBuffer(length);
SecureRandom rand = new SecureRandom();
for (int i = 0; i < length; i++) {
buf.append(rand.nextInt(digits.length));
}
return buf.toString();
} | java | {
"resource": ""
} |
q155067 | XianDataSource.getHost | train | public String getHost() {
String hostAndPort = hostAndPort();
int indexOfMaohao = hostAndPort.indexOf(":");
if (indexOfMaohao == -1) {
return hostAndPort;
} else {
return hostAndPort.substring(0, indexOfMaohao);
}
} | java | {
"resource": ""
} |
q155068 | XianDataSource.getPort | train | public int getPort() {
String hostAndPort = hostAndPort();
int indexOfMaohao = hostAndPort.indexOf(":");
if (indexOfMaohao == -1) {
return 3306;
} else {
return Integer.parseInt(hostAndPort.substring(indexOfMaohao + 1));
}
} | java | {
"resource": ""
} |
q155069 | XianDataSource.hostAndPort | train | private String hostAndPort() {
int start = url.indexOf("://") + 3;
int end = url.indexOf("/", start);
return url.substring(start, end);
} | java | {
"resource": ""
} |
q155070 | XianDataSource.getDatabase | train | public String getDatabase() {
int indexSlash = url.indexOf("/", url.indexOf("://") + 3);
int questionMarkIndex = url.indexOf("?");
if (questionMarkIndex != -1) {
return url.substring(indexSlash + 1, questionMarkIndex);
} else {
return url.substring(indexSlash + 1)... | java | {
"resource": ""
} |
q155071 | MsgIdHolder.set | train | public static boolean set(String value) {
if (StringUtil.isEmpty(value)) {
throw new IllegalArgumentException("Can not set an empty msgId. If you want to clear msgId of current context, use clear() instead.");
}
if (Objects.equals(value, MsgIdHolder.get())) {
//no need ma... | java | {
"resource": ""
} |
q155072 | SqlUtils.formatMap | train | public static Map formatMap(Map conditionMap) {
Map formattedMap = new HashMap();
formattedMap.putAll(conditionMap);
forSpecialValue(formattedMap);
return formattedMap;
} | java | {
"resource": ""
} |
q155073 | GelfMessageBuilder.withField | train | public GelfMessageBuilder withField(String key, String value) {
this.additionalFields.put(key, value);
return this;
} | java | {
"resource": ""
} |
q155074 | InterProcessMutex.release | train | @Override
public void release() throws Exception
{
/*
Note on concurrency: a given lockData instance
can be only acted on by a single thread so locking isn't necessary
*/
Thread currentThread = Thread.currentThread();
LockData lockData = threadData.get(c... | java | {
"resource": ""
} |
q155075 | InterProcessMutex.getParticipantNodes | train | public Collection<String> getParticipantNodes() throws Exception
{
return LockInternals.getParticipantNodes(internals.getClient(), basePath, internals.getLockName(), internals.getDriver());
} | java | {
"resource": ""
} |
q155076 | InputValidator.validate | train | public static <T> T validate(InputStream input, final Class<T> clazz) throws IOException {
return JSON.parseObject(input, clazz);
} | java | {
"resource": ""
} |
q155077 | StaticNodeIdManager.getStaticNodeId | train | public static String getStaticNodeId(String nodeId) {
String application = NodeIdBean.parse(nodeId).getApplication();
if (nodeId_to_StaticFinalId_map.get(nodeId) == null) {
Instance<NodeStatus> instance = ApplicationDiscovery.singleton.instance(nodeId);
if (instance != null) {
... | java | {
"resource": ""
} |
q155078 | PoolingGelfMessageBuilder.build | train | public GelfMessage build() {
GelfMessage gelfMessage = new PoolingGelfMessage(shortMessage, fullMessage, javaTimestamp, level, poolHolder);
gelfMessage.addFields(additionalFields);
gelfMessage.setMaximumMessageSize(maximumMessageSize);
gelfMessage.setVersion(version);
gelfMessag... | java | {
"resource": ""
} |
q155079 | Reflection.getNonAbstractSubclasses | train | public static <T> Set<Class<? extends T>> getNonAbstractSubclasses(Class<T> clazz) {
return ClassGraphUtil/*TraverseClasspath*/.getNonAbstractSubClasses(clazz);
} | java | {
"resource": ""
} |
q155080 | Reflection.getWithAnnotatedClass | train | public static <T> List<T> getWithAnnotatedClass(Class annotationClass, String packages) {
return new ArrayList<T>() {{
addAll(ClassGraphUtil.getWithAnnotatedClass(annotationClass, packages));
}};
} | java | {
"resource": ""
} |
q155081 | Reflection.getPrimitiveType | train | public static Class getPrimitiveType(Class type) {
if (type == int.class || type == Integer.class) {
return int.class;
} else if (type == long.class || type == Long.class) {
return long.class;
} else if (type == short.class || type == Short.class) {
return sho... | java | {
"resource": ""
} |
q155082 | Reflection.cast | train | @SuppressWarnings("unchecked")
private static <T> T cast(Object obj, Class<T> clazz) {
if (obj == null) {
return null;
}
if (clazz == null) {
throw new IllegalArgumentException("parameter 'Class<T> clazz' is not allowed to be null.");
}
if (clazz.isEnu... | java | {
"resource": ""
} |
q155083 | Reflection.toTypedSet | train | @SuppressWarnings("all")
public static <T> Set<T> toTypedSet(Object data, Class<T> type) {
Set<T> setResult = new HashSet<>();
if (data == null) {
return setResult;
}
if (data instanceof Collection) {
Collection collection = (Collection) data;
for ... | java | {
"resource": ""
} |
q155084 | Reflection.getAllFieldsRec | train | private static List<Field> getAllFieldsRec(Class clazz, List<Field> fieldList) {
Class superClazz = clazz.getSuperclass();
if (superClazz != null) {
getAllFieldsRec(superClazz, fieldList);
}
fieldList.addAll(ArrayUtil.toList(clazz.getDeclaredFields(), Field.class));
r... | java | {
"resource": ""
} |
q155085 | ConnectionStateManager.start | train | public void start()
{
Preconditions.checkState(state.compareAndSet(State.LATENT, State.STARTED), "Cannot be started more than once");
service.submit
(
new Callable<Object>()
{
@Override
public Object call() throws E... | java | {
"resource": ""
} |
q155086 | ConnectionStateManager.addStateChange | train | public synchronized boolean addStateChange(ConnectionState newConnectionState)
{
if ( state.get() != State.STARTED )
{
return false;
}
ConnectionState previousState = currentConnectionState;
if ( previousState == newConnectionState )
{
return ... | java | {
"resource": ""
} |
q155087 | ConnectionState.getSessionId | train | public long getSessionId() {
long sessionId = 0;
try {
ZooKeeper zk = zooKeeper.getZooKeeper();
if (zk != null) {
sessionId = zk.getSessionId();
}
} catch (Exception e) {
// Ignore the exception
}
return sessionId;
... | java | {
"resource": ""
} |
q155088 | UnitRequest.get | train | public <T> T get(String key, Class<T> clazz, T defaultValue) {
Object obj = argMap.get(key);
if (obj == null) {
return defaultValue;
}
return Reflection.toType(obj, clazz);
} | java | {
"resource": ""
} |
q155089 | UnitRequest.getSet | train | @SuppressWarnings("unchecked")
public <T> Set<T> getSet(String key) {
return Reflection.toType(get(key), Set.class);
} | java | {
"resource": ""
} |
q155090 | UnitRequest.getArgBean | train | public <T> T getArgBean(Class<? extends T> beanClass) {
return Reflection.toType(argMap, beanClass);
} | java | {
"resource": ""
} |
q155091 | UnitRequest.create | train | public static UnitRequest create(String group, String unit) {
return new UnitRequest().setContext(RequestContext.create().setGroup(group).setUnit(unit));
} | java | {
"resource": ""
} |
q155092 | UnitRequest.create | train | public static UnitRequest create(Class<? extends Unit> unitClass) {
Unit unit = LocalUnitsManager.getUnitByUnitClass(unitClass);
return create(unit.getGroup().getName(), unit.getName());
} | java | {
"resource": ""
} |
q155093 | LeaderLatch.start | train | public void start() throws Exception
{
Preconditions.checkState(state.compareAndSet(State.LATENT, State.STARTED), "Cannot be started more than once");
startTask.set(AfterConnectionEstablished.execute(client, new Runnable()
{
@Override
public v... | java | {
"resource": ""
} |
q155094 | DistributedQueue.start | train | @Override
public void start() throws Exception
{
if ( !state.compareAndSet(State.LATENT, State.STARTED) )
{
throw new IllegalStateException();
}
try
{
client.create().creatingParentContainersIfNeeded().forPath(queuePath);
}
cat... | java | {
"resource": ""
} |
q155095 | DistributedQueue.flushPuts | train | @Override
public boolean flushPuts(long waitTime, TimeUnit timeUnit) throws InterruptedException
{
long msWaitRemaining = TimeUnit.MILLISECONDS.convert(waitTime, timeUnit);
synchronized(putCount)
{
while ( putCount.get() > 0 )
{
if ( msWaitRemai... | java | {
"resource": ""
} |
q155096 | DistributedIdQueue.remove | train | public int remove(String id) throws Exception
{
id = Preconditions.checkNotNull(id, "id cannot be null");
queue.checkState();
int count = 0;
for ( String name : queue.getChildren() )
{
if ( parseId(name).id.equals(id) )
{
if ( que... | java | {
"resource": ""
} |
q155097 | PluginConfig.extendedKey | train | private static String extendedKey(Properties properties, String key) {
String extendedKey = extendedKey(key);
return properties.containsKey(extendedKey) ? extendedKey : key;
} | java | {
"resource": ""
} |
q155098 | SessionFailRetryLoop.start | train | public void start()
{
Preconditions.checkState(Thread.currentThread().equals(ourThread), "Not in the correct thread");
client.addParentWatcher(watcher);
} | java | {
"resource": ""
} |
q155099 | SessionFailRetryLoop.close | train | @Override
public void close()
{
Preconditions.checkState(Thread.currentThread().equals(ourThread), "Not in the correct thread");
failedSessionThreads.remove(ourThread);
client.removeParentWatcher(watcher);
} | java | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.