code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
@Override
public ByteBuffer getBytes() {
ByteBuffer bb = ByteBuffer.allocate(HEADER_LENGTH + getTotalbody());
bb.put(magic.getMagic());
bb.put(opcode.getOpcode());
bb.putShort(keylength);
bb.put(extralength);
bb.put(datatype);
bb.putShort(vbucket);
bb.putInt(totalbody);
bb.putInt(o... | java |
protected Future<T> addToListeners(
final GenericCompletionListener<? extends Future<T>> listener) {
if (listener == null) {
throw new IllegalArgumentException("The listener can't be null.");
}
synchronized(this) {
listeners.add(listener);
}
if(isDone()) {
notifyListeners();
... | java |
protected void notifyListener(final ExecutorService executor,
final Future<?> future, final GenericCompletionListener listener) {
executor.submit(new Runnable() {
@Override
public void run() {
try {
listener.onComplete(future);
} catch(Throwable t) {
getLogger().w... | java |
protected void notifyListeners(final Future<?> future) {
final List<GenericCompletionListener<? extends Future<T>>> copy =
new ArrayList<GenericCompletionListener<? extends Future<T>>>();
synchronized(this) {
copy.addAll(listeners);
listeners = new ArrayList<GenericCompletionListener<? extends... | java |
protected Future<T> removeFromListeners(
GenericCompletionListener<? extends Future<T>> listener) {
if (listener == null) {
throw new IllegalArgumentException("The listener can't be null.");
}
if (!isDone()) {
synchronized(this) {
listeners.remove(listener);
}
}
return... | java |
protected void registerMetrics() {
if (metricType.equals(MetricType.DEBUG)
|| metricType.equals(MetricType.PERFORMANCE)) {
metrics.addHistogram(OVERALL_AVG_BYTES_READ_METRIC);
metrics.addHistogram(OVERALL_AVG_BYTES_WRITE_METRIC);
metrics.addHistogram(OVERALL_AVG_TIME_ON_WIRE_METRIC);
m... | java |
protected List<MemcachedNode> createConnections(
final Collection<InetSocketAddress> addrs) throws IOException {
List<MemcachedNode> connections = new ArrayList<MemcachedNode>(addrs.size());
for (SocketAddress sa : addrs) {
SocketChannel ch = SocketChannel.open();
ch.configureBlocking(false);
... | java |
private boolean selectorsMakeSense() {
for (MemcachedNode qa : locator.getAll()) {
if (qa.getSk() != null && qa.getSk().isValid()) {
if (qa.getChannel().isConnected()) {
int sops = qa.getSk().interestOps();
int expected = 0;
if (qa.hasReadOp()) {
expected |= S... | java |
public void handleIO() throws IOException {
if (shutDown) {
getLogger().debug("No IO while shut down.");
return;
}
handleInputQueue();
getLogger().debug("Done dealing with queue.");
long delay = wakeupDelay;
if (!reconnectQueue.isEmpty()) {
long now = System.currentTimeMillis... | java |
private void handleShutdownQueue() throws IOException {
for (MemcachedNode qa : nodesToShutdown) {
if (!addedQueue.contains(qa)) {
nodesToShutdown.remove(qa);
metrics.decrementCounter(SHUTD_QUEUE_METRIC);
Collection<Operation> notCompletedOperations = qa.destroyInputQueue();
if... | java |
private void checkPotentiallyTimedOutConnection() {
boolean stillCheckingTimeouts = true;
while (stillCheckingTimeouts) {
try {
for (SelectionKey sk : selector.keys()) {
MemcachedNode mn = (MemcachedNode) sk.attachment();
if (mn.getContinuousTimeout() > timeoutExceptionThreshol... | java |
private void handleInputQueue() {
if (!addedQueue.isEmpty()) {
getLogger().debug("Handling queue");
Collection<MemcachedNode> toAdd = new HashSet<MemcachedNode>();
Collection<MemcachedNode> todo = new HashSet<MemcachedNode>();
MemcachedNode qaNode;
while ((qaNode = addedQueue.poll()) ... | java |
private void connected(final MemcachedNode node) {
assert node.getChannel().isConnected() : "Not connected.";
int rt = node.getReconnectCount();
node.connected();
for (ConnectionObserver observer : connObservers) {
observer.connectionEstablished(node.getSocketAddress(), rt);
}
} | java |
private void lostConnection(final MemcachedNode node) {
queueReconnect(node);
for (ConnectionObserver observer : connObservers) {
observer.connectionLost(node.getSocketAddress());
}
} | java |
boolean belongsToCluster(final MemcachedNode node) {
for (MemcachedNode n : locator.getAll()) {
if (n.getSocketAddress().equals(node.getSocketAddress())) {
return true;
}
}
return false;
} | java |
private void handleIO(final SelectionKey sk) {
MemcachedNode node = (MemcachedNode) sk.attachment();
try {
getLogger().debug("Handling IO for: %s (r=%s, w=%s, c=%s, op=%s)", sk,
sk.isReadable(), sk.isWritable(), sk.isConnectable(),
sk.attachment());
if (sk.isConnectable() && belong... | java |
private void finishConnect(final SelectionKey sk, final MemcachedNode node)
throws IOException {
if (verifyAliveOnConnect) {
final CountDownLatch latch = new CountDownLatch(1);
final OperationFuture<Boolean> rv = new OperationFuture<Boolean>("noop",
latch, 2500, listenerExecutorService);
... | java |
private void handleWrites(final MemcachedNode node) throws IOException {
node.fillWriteBuffer(shouldOptimize);
boolean canWriteMore = node.getBytesRemainingToWrite() > 0;
while (canWriteMore) {
int wrote = node.writeSome();
metrics.updateHistogram(OVERALL_AVG_BYTES_WRITE_METRIC, wrote);
no... | java |
private void handleReads(final MemcachedNode node) throws IOException {
Operation currentOp = node.getCurrentReadOp();
if (currentOp instanceof TapAckOperationImpl) {
node.removeCurrentReadOp();
return;
}
ByteBuffer rbuf = node.getRbuf();
final SocketChannel channel = node.getChannel();... | java |
private void readBufferAndLogMetrics(final Operation currentOp,
final ByteBuffer rbuf, final MemcachedNode node) throws IOException {
currentOp.readFromBuffer(rbuf);
if (currentOp.getState() == OperationState.COMPLETE) {
getLogger().debug("Completed read op: %s and giving the next %d "
+ "byte... | java |
private Operation handleReadsWhenChannelEndOfStream(final Operation currentOp,
final MemcachedNode node, final ByteBuffer rbuf) throws IOException {
if (currentOp instanceof TapOperation) {
currentOp.getCallback().complete();
((TapOperation) currentOp).streamClosed(OperationState.COMPLETE);
g... | java |
private void potentiallyCloseLeakingChannel(final SocketChannel ch,
final MemcachedNode node) {
if (ch != null && !ch.isConnected() && !ch.isConnectionPending()) {
try {
ch.close();
} catch (IOException e) {
getLogger().error("Exception closing channel: %s", node, e);
}
}
... | java |
protected void addOperation(final String key, final Operation o) {
MemcachedNode placeIn = null;
MemcachedNode primary = locator.getPrimary(key);
if (primary.isActive() || failureMode == FailureMode.Retry) {
placeIn = primary;
} else if (failureMode == FailureMode.Cancel) {
o.cancel();
... | java |
public void insertOperation(final MemcachedNode node, final Operation o) {
o.setHandlingNode(node);
o.initialize();
node.insertOp(o);
addedQueue.offer(node);
metrics.markMeter(OVERALL_REQUEST_METRIC);
Selector s = selector.wakeup();
assert s == selector : "Wakeup returned the wrong selector... | java |
protected void addOperation(final MemcachedNode node, final Operation o) {
if (!node.isAuthenticated()) {
retryOperation(o);
return;
}
o.setHandlingNode(node);
o.initialize();
node.addOp(o);
addedQueue.offer(node);
metrics.markMeter(OVERALL_REQUEST_METRIC);
Selector s = sele... | java |
public void addOperations(final Map<MemcachedNode, Operation> ops) {
for (Map.Entry<MemcachedNode, Operation> me : ops.entrySet()) {
addOperation(me.getKey(), me.getValue());
}
} | java |
public CountDownLatch broadcastOperation(final BroadcastOpFactory of,
final Collection<MemcachedNode> nodes) {
final CountDownLatch latch = new CountDownLatch(nodes.size());
for (MemcachedNode node : nodes) {
getLogger().debug("broadcast Operation: node = " + node);
Operation op = of.newOp(node... | java |
public void shutdown() throws IOException {
shutDown = true;
try {
Selector s = selector.wakeup();
assert s == selector : "Wakeup returned the wrong selector.";
for (MemcachedNode node : locator.getAll()) {
if (node.getChannel() != null) {
node.getChannel().close();
... | java |
public String connectionsStatus() {
StringBuilder connStatus = new StringBuilder();
connStatus.append("Connection Status {");
for (MemcachedNode node : locator.getAll()) {
connStatus
.append(" ")
.append(node.getSocketAddress())
.append(" active: ")
.append(node.isActiv... | java |
private static void setTimeout(final Operation op, final boolean isTimeout) {
Logger logger = LoggerFactory.getLogger(MemcachedConnection.class);
try {
if (op == null || op.isTimedOutUnsent()) {
return;
}
MemcachedNode node = op.getHandlingNode();
if (node != null) {
no... | java |
@Override
public void run() {
while (running) {
try {
handleIO();
} catch (IOException e) {
logRunException(e);
} catch (CancelledKeyException e) {
logRunException(e);
} catch (ClosedSelectorException e) {
logRunException(e);
} catch (IllegalStateExcep... | java |
private void logRunException(final Exception e) {
if (shutDown) {
getLogger().debug("Exception occurred during shutdown", e);
} else {
getLogger().warn("Problem handling memcached IO", e);
}
} | java |
public void retryOperation(Operation op) {
if (retryQueueSize >= 0 && retryOps.size() >= retryQueueSize) {
if (!op.isCancelled()) {
op.cancel();
}
}
retryOps.add(op);
} | java |
public <T> Future<T> decode(final Transcoder<T> tc,
final CachedData cachedData) {
assert !pool.isShutdown() : "Pool has already shut down.";
TranscodeService.Task<T> task =
new TranscodeService.Task<T>(new Callable<T>() {
public T call() {
return tc.decode(cachedData);
... | java |
private Object deserialize() {
SerializingTranscoder tc = new SerializingTranscoder();
CachedData d = new CachedData(this.getItemFlags(), this.getValue(),
CachedData.MAX_SIZE);
Object rv = null;
rv = tc.decode(d);
return rv;
} | java |
public static void close(Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (Exception e) {
logger.info("Unable to close %s", closeable, e);
}
}
} | java |
public static synchronized HashAlgorithm lookupHashAlgorithm(String name) {
validateName(name);
return REGISTRY.get(name.toLowerCase());
} | java |
@Override
public Collection<SocketAddress> getUnavailableServers() {
ArrayList<SocketAddress> rv = new ArrayList<SocketAddress>();
for (MemcachedNode node : mconn.getLocator().getAll()) {
if (!node.isActive()) {
rv.add(node.getSocketAddress());
}
}
return rv;
} | java |
@Override
public <T> OperationFuture<Boolean> touch(final String key, final int exp) {
return touch(key, exp, transcoder);
} | java |
@Override
public <T> OperationFuture<Boolean> touch(final String key, final int exp,
final Transcoder<T> tc) {
final CountDownLatch latch = new CountDownLatch(1);
final OperationFuture<Boolean> rv =
new OperationFuture<Boolean>(key, latch, operationTimeout,
executorService);
Operation o... | java |
@Override
public OperationFuture<CASResponse>
asyncCAS(String key, long casId, Object value) {
return asyncCAS(key, casId, value, transcoder);
} | java |
@Override
public CASResponse cas(String key, long casId, Object value) {
return cas(key, casId, value, transcoder);
} | java |
@Override
public <T> OperationFuture<Boolean> add(String key, int exp, T o,
Transcoder<T> tc) {
return asyncStore(StoreType.add, key, exp, o, tc);
} | java |
@Override
public <T> GetFuture<T> asyncGet(final String key, final Transcoder<T> tc) {
final CountDownLatch latch = new CountDownLatch(1);
final GetFuture<T> rv = new GetFuture<T>(latch, operationTimeout, key,
executorService);
Operation op = opFact.get(key, new GetOperation.Callback() {
priv... | java |
@Override
public <T> CASValue<T> getAndTouch(String key, int exp, Transcoder<T> tc) {
try {
return asyncGetAndTouch(key, exp, tc).get(operationTimeout,
TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
throw new RuntimeException("Interrupted waiting for value", e);
} catch (... | java |
@Override
public CASValue<Object> getAndTouch(String key, int exp) {
return getAndTouch(key, exp, transcoder);
} | java |
@Override
public <T> T get(String key, Transcoder<T> tc) {
try {
return asyncGet(key, tc).get(operationTimeout, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
throw new RuntimeException("Interrupted waiting for value", e);
} catch (ExecutionException e) {
if(e.getCause() inst... | java |
@Override
public <T> BulkFuture<Map<String, T>> asyncGetBulk(Transcoder<T> tc,
String... keys) {
return asyncGetBulk(Arrays.asList(keys), tc);
} | java |
@Override
public BulkFuture<Map<String, Object>> asyncGetBulk(String... keys) {
return asyncGetBulk(Arrays.asList(keys), transcoder);
} | java |
@Override
public OperationFuture<CASValue<Object>> asyncGetAndTouch(final String key,
final int exp) {
return asyncGetAndTouch(key, exp, transcoder);
} | java |
@Override
public Map<SocketAddress, String> getVersions() {
final Map<SocketAddress, String> rv =
new ConcurrentHashMap<SocketAddress, String>();
CountDownLatch blatch = broadcastOp(new BroadcastOpFactory() {
@Override
public Operation newOp(final MemcachedNode n,
final CountDow... | java |
@Override
public Map<SocketAddress, Map<String, String>> getStats(final String arg) {
final Map<SocketAddress, Map<String, String>> rv =
new HashMap<SocketAddress, Map<String, String>>();
CountDownLatch blatch = broadcastOp(new BroadcastOpFactory() {
@Override
public Operation newOp(final... | java |
@Override
public long incr(String key, int by) {
return mutate(Mutator.incr, key, by, 0, -1);
} | java |
@Override
public long decr(String key, long by) {
return mutate(Mutator.decr, key, by, 0, -1);
} | java |
@Override
public OperationFuture<Long> asyncDecr(String key, int by, long def,
int exp) {
return asyncMutate(Mutator.decr, key, by, def, exp);
} | java |
@Override
public OperationFuture<Long> asyncIncr(String key, long by, long def) {
return asyncMutate(Mutator.incr, key, by, def, 0);
} | java |
@Override
public long incr(String key, long by, long def) {
return mutateWithDefault(Mutator.incr, key, by, def, 0);
} | java |
@Override
public OperationFuture<Boolean> delete(String key, long cas) {
final CountDownLatch latch = new CountDownLatch(1);
final OperationFuture<Boolean> rv = new OperationFuture<Boolean>(key,
latch, operationTimeout, executorService);
DeleteOperation.Callback callback = new DeleteOperation.Cal... | java |
@Override
public OperationFuture<Boolean> flush(final int delay) {
final AtomicReference<Boolean> flushResult =
new AtomicReference<Boolean>(null);
final ConcurrentLinkedQueue<Operation> ops =
new ConcurrentLinkedQueue<Operation>();
CountDownLatch blatch = broadcastOp(new BroadcastOpFactor... | java |
@Override
public boolean waitForQueues(long timeout, TimeUnit unit) {
CountDownLatch blatch = broadcastOp(new BroadcastOpFactory() {
@Override
public Operation newOp(final MemcachedNode n,
final CountDownLatch latch) {
return opFact.noop(new OperationCallback() {
@Override
... | java |
public ConnectionFactoryBuilder setProtocol(Protocol prot) {
switch (prot) {
case TEXT:
opFact = new AsciiOperationFactory();
break;
case BINARY:
opFact = new BinaryOperationFactory();
break;
default:
assert false : "Unhandled protocol: " + prot;
}
return this;
} | java |
public T cas(final String key, final T initial, int initialExp,
final CASMutation<T> m) throws Exception {
T rv = initial;
boolean done = false;
for (int i = 0; !done && i < max; i++) {
CASValue<T> casval = client.gets(key, transcoder);
T current = null;
// If there were a CAS value... | java |
@Override
public void run() {
try {
barrier.await();
rv = callable.call();
} catch (Throwable t) {
throwable = t;
}
latch.countDown();
} | java |
public static <T> Collection<SyncThread<T>> getCompletedThreads(int num,
Callable<T> callable) throws InterruptedException {
Collection<SyncThread<T>> rv = new ArrayList<SyncThread<T>>(num);
CyclicBarrier barrier = new CyclicBarrier(num);
for (int i = 0; i < num; i++) {
rv.add(new SyncThread<T>... | java |
public static <T> int getDistinctResultCount(int num, Callable<T> callable)
throws Throwable {
IdentityHashMap<T, Object> found = new IdentityHashMap<T, Object>();
Collection<SyncThread<T>> threads = getCompletedThreads(num, callable);
for (SyncThread<T> s : threads) {
found.put(s.getResult(), new... | java |
@Override
public void log(Level level, Object message, Throwable e) {
org.apache.log4j.Level pLevel = org.apache.log4j.Level.DEBUG;
switch (level == null ? Level.FATAL : level) {
case TRACE:
pLevel = org.apache.log4j.Level.TRACE;
break;
case DEBUG:
pLevel = org.apache.log4j.Level.DE... | java |
protected String decodeString(byte[] data) {
String rv = null;
try {
if (data != null) {
rv = new String(data, charset);
}
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
return rv;
} | java |
public <T> Future<?> loadData(Iterator<Map.Entry<String, T>> i) {
Future<Boolean> mostRecent = null;
while (i.hasNext()) {
Map.Entry<String, T> e = i.next();
mostRecent = push(e.getKey(), e.getValue());
watch(e.getKey(), mostRecent);
}
return mostRecent == null ? new ImmediateFuture(t... | java |
public <T> Future<?> loadData(Map<String, T> map) {
return loadData(map.entrySet().iterator());
} | java |
public <T> Future<Boolean> push(String k, T value) {
Future<Boolean> rv = null;
while (rv == null) {
try {
rv = client.set(k, expiration, value);
} catch (IllegalStateException ex) {
// Need to slow down a bit when we start getting rejections.
try {
if (rv != null) ... | java |
@Override
public void log(Level level, Object message, Throwable e) {
java.util.logging.Level sLevel = java.util.logging.Level.SEVERE;
switch (level == null ? Level.FATAL : level) {
case TRACE:
sLevel = java.util.logging.Level.FINEST;
break;
case DEBUG:
sLevel = java.util.logging.Le... | java |
public static String join(final Collection<String> chunks,
final String delimiter) {
StringBuilder sb = new StringBuilder();
if (!chunks.isEmpty()) {
Iterator<String> itr = chunks.iterator();
sb.append(itr.next());
while (itr.hasNext()) {
sb.append(delimiter);
sb.append(itr... | java |
public static boolean isJsonObject(final String s) {
if (s == null || s.isEmpty()) {
return false;
}
if (s.startsWith("{") || s.startsWith("[")
|| "true".equals(s) || "false".equals(s)
|| "null".equals(s) || decimalPattern.matcher(s).matches()) {
return true;
}
return false... | java |
public static void validateKey(final String key, final boolean binary) {
byte[] keyBytes = KeyUtil.getKeyBytes(key);
int keyLength = keyBytes.length;
if (keyLength > MAX_KEY_LENGTH) {
throw KEY_TOO_LONG_EXCEPTION;
}
if (keyLength == 0) {
throw KEY_EMPTY_EXCEPTION;
}
if(!binary... | java |
public String getKeyForNode(MemcachedNode node, int repetition) {
// Carrried over from the DefaultKetamaNodeLocatorConfiguration:
// Internal Using the internal map retrieve the socket addresses
// for given nodes.
// I'm aware that this code is inherently thread-unsafe as
// I'... | java |
protected final OperationStatus matchStatus(String line,
OperationStatus... statii) {
OperationStatus rv = null;
for (OperationStatus status : statii) {
if (line.equals(status.getMessage())) {
rv = status;
}
}
if (rv == null) {
rv = new OperationStatus(false, line, Status... | java |
protected final void setArguments(ByteBuffer bb, Object... args) {
boolean wasFirst = true;
for (Object o : args) {
if (wasFirst) {
wasFirst = false;
} else {
bb.put((byte) ' ');
}
bb.put(KeyUtil.getKeyBytes(String.valueOf(o)));
}
bb.put(CRLF);
} | java |
private Animator preparePressedAnimation() {
Animator animation = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.CIRCLE_SCALE_PROPERTY,
drawable.getCircleScale(), 0.65f);
animation.setDuration(120);
return animation;
} | java |
private Animator preparePulseAnimation() {
AnimatorSet animation = new AnimatorSet();
Animator firstBounce = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.CIRCLE_SCALE_PROPERTY,
drawable.getCircleScale(), 0.88f);
firstBounce.setDuration(300);
firstBounce.setI... | java |
private Animator prepareStyle1Animation() {
AnimatorSet animation = new AnimatorSet();
final Animator indeterminateAnimation = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.PROGRESS_PROPERTY, 0, 3600);
indeterminateAnimation.setDuration(3600);
Animator innerCircleAnimation ... | java |
private Animator prepareStyle2Animation() {
AnimatorSet animation = new AnimatorSet();
ObjectAnimator progressAnimation = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.PROGRESS_PROPERTY,
0f, 1f);
progressAnimation.setDuration(3600);
progressAnimation.setInter... | java |
private int readDefaultLine(Text str, int maxLineLength, int maxBytesToConsume)
throws IOException
{
/* We're reading data from in, but the head of the stream may be
* already buffered in buffer, so we have several cases:
* 1. No newline characters are in the buffer, so we need... | java |
public void installOrUpdateScanner(File installDirectory) throws BlackDuckIntegrationException {
File scannerExpansionDirectory = new File(installDirectory, ScannerZipInstaller.BLACK_DUCK_SIGNATURE_SCANNER_INSTALL_DIRECTORY);
scannerExpansionDirectory.mkdirs();
File versionFile = null;
... | java |
public List<ScanCommand> createScanCommands(final File defaultInstallDirectory, final ScanPathsUtility scanPathsUtility, final IntEnvironmentVariables intEnvironmentVariables) throws BlackDuckIntegrationException {
String scanCliOptsToUse = scanCliOpts;
if (null != intEnvironmentVariables && StringUtils... | java |
private String createPrintableCommand(final List<String> cmd) {
final List<String> cmdToOutput = new ArrayList<>();
cmdToOutput.addAll(cmd);
int passwordIndex = cmdToOutput.indexOf("--password");
if (passwordIndex > -1) {
// The User's password will be at the next index
... | java |
public void populateApplicationId(ProjectView projectView, String applicationId) throws IntegrationException {
List<ProjectMappingView> projectMappings = blackDuckService.getAllResponses(projectView, ProjectView.PROJECT_MAPPINGS_LINK_RESPONSE);
boolean canCreate = projectMappings.isEmpty();
if (... | java |
public String generateBlackDuckNoticesReport(ProjectVersionView version, ReportFormatType reportFormat) throws InterruptedException, IntegrationException {
if (version.hasLink(ProjectVersionView.LICENSEREPORTS_LINK)) {
try {
logger.debug("Starting the Notices Report generation.");
... | java |
public ReportView isReportFinishedGenerating(String reportUri) throws InterruptedException, IntegrationException {
long startTime = System.currentTimeMillis();
long elapsedTime = 0;
Date timeFinished = null;
ReportView reportInfo = null;
while (timeFinished == null) {
... | java |
public Set<UserView> getAllActiveUsersForProject(ProjectView projectView) throws IntegrationException {
Set<UserView> users = new HashSet<>();
List<AssignedUserGroupView> assignedGroups = getAssignedGroupsToProject(projectView);
for (AssignedUserGroupView assignedUserGroupView : assignedGroups)... | java |
public String createPolicyRuleForExternalId(ComponentService componentService, ExternalId externalId, String policyName) throws IntegrationException {
Optional<ComponentVersionView> componentVersionView = componentService.getComponentVersion(externalId);
if (!componentVersionView.isPresent()) {
... | java |
public static void kill(final long pid) throws IOException, InterruptedException {
if (isUnix()) {
final Process process = new ProcessBuilder()
.command("bash", "-c", "kill", "-9", String.valueOf(pid))
.start();
final int returnCode = process.waitFor();
LOG.fine("Kill returned:... | java |
@SuppressWarnings("checkstyle:hiddenfield")
public <T, U extends T> void register(final Class<T> type, final Set<EventHandler<U>> handlers) {
this.handlers.put(type, new ExceptionHandlingEventHandler<>(
new BroadCastEventHandler<>(handlers), this.errorHandler));
} | java |
@SuppressWarnings("unchecked")
public <T, U extends T> void onNext(final Class<T> type, final U message) {
if (this.isClosed()) {
LOG.log(Level.WARNING, "Dispatcher {0} already closed: ignoring message {1}: {2}",
new Object[] {this.stage, type.getCanonicalName(), message});
} else {
fina... | java |
@Override
public InetSocketAddress lookup(final Identifier id) throws Exception {
return cache.get(id, new Callable<InetSocketAddress>() {
@Override
public InetSocketAddress call() throws Exception {
final int origRetryCount = NameLookupClient.this.retryCount;
int retriesLeft = origR... | java |
public InetSocketAddress remoteLookup(final Identifier id) throws Exception {
// the lookup is not thread-safe, because concurrent replies may
// be read by the wrong thread.
// TODO: better fix uses a map of id's after REEF-198
synchronized (this) {
LOG.log(Level.INFO, "Looking up {0} on NameSer... | java |
public void scheduleTasklet(final int taskletId) {
synchronized (stateLock) {
// If there are tasklets are pending to be executed, then that means that a
// timer has already been scheduled for an aggregation.
if (!outstandingTasklets()) {
timer.schedule(new Runnable() {
@Overrid... | java |
public void taskletComplete(final int taskletId, final Object result) {
final boolean aggregateOnCount;
synchronized (stateLock) {
completedTasklets.add(new ImmutablePair<>(taskletId, result));
removePendingTaskletReferenceCount(taskletId);
aggregateOnCount = aggregateOnCount();
}
if ... | java |
public void taskletFailed(final int taskletId, final Exception e) {
final boolean aggregateOnCount;
synchronized (stateLock) {
failedTasklets.add(new ImmutablePair<>(taskletId, e));
removePendingTaskletReferenceCount(taskletId);
aggregateOnCount = aggregateOnCount();
}
if (aggregateOn... | java |
@Override
public void onNext(final Integer integer) {
while (!runningWorkers.isTerminated()) {
try {
final Tasklet tasklet = pendingTasklets.takeFirst(); // blocks when no tasklet exists
runningWorkers.launchTasklet(tasklet); // blocks when no worker exists
} catch (InterruptedExceptio... | java |
private String getQueue(final JobSubmissionEvent jobSubmissionEvent) {
try {
return Tang.Factory.getTang().newInjector(
jobSubmissionEvent.getConfiguration()).getNamedInstance(JobQueue.class);
} catch (final InjectionException e) {
return this.defaultQueueName;
}
} | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.