repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
dustin/java-memcached-client | src/main/java/net/spy/memcached/tapmessage/RequestMessage.java | RequestMessage.getBytes | @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 | @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... | [
"@",
"Override",
"public",
"ByteBuffer",
"getBytes",
"(",
")",
"{",
"ByteBuffer",
"bb",
"=",
"ByteBuffer",
".",
"allocate",
"(",
"HEADER_LENGTH",
"+",
"getTotalbody",
"(",
")",
")",
";",
"bb",
".",
"put",
"(",
"magic",
".",
"getMagic",
"(",
")",
")",
"... | Encodes the message into binary. | [
"Encodes",
"the",
"message",
"into",
"binary",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/tapmessage/RequestMessage.java#L150-L189 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/internal/AbstractListenableFuture.java | AbstractListenableFuture.addToListeners | 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 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();
... | [
"protected",
"Future",
"<",
"T",
">",
"addToListeners",
"(",
"final",
"GenericCompletionListener",
"<",
"?",
"extends",
"Future",
"<",
"T",
">",
">",
"listener",
")",
"{",
"if",
"(",
"listener",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentExcepti... | Add the given listener to the total list of listeners to be notified.
<p>If the future is already done, the listener will be notified
immediately.</p>
@param listener the listener to add.
@return the current future to allow chaining. | [
"Add",
"the",
"given",
"listener",
"to",
"the",
"total",
"list",
"of",
"listeners",
"to",
"be",
"notified",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/internal/AbstractListenableFuture.java#L87-L102 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/internal/AbstractListenableFuture.java | AbstractListenableFuture.notifyListener | 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 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... | [
"protected",
"void",
"notifyListener",
"(",
"final",
"ExecutorService",
"executor",
",",
"final",
"Future",
"<",
"?",
">",
"future",
",",
"final",
"GenericCompletionListener",
"listener",
")",
"{",
"executor",
".",
"submit",
"(",
"new",
"Runnable",
"(",
")",
"... | Notify a specific listener of completion.
@param executor the executor to use.
@param future the future to hand over.
@param listener the listener to notify. | [
"Notify",
"a",
"specific",
"listener",
"of",
"completion",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/internal/AbstractListenableFuture.java#L111-L125 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/internal/AbstractListenableFuture.java | AbstractListenableFuture.notifyListeners | 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 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... | [
"protected",
"void",
"notifyListeners",
"(",
"final",
"Future",
"<",
"?",
">",
"future",
")",
"{",
"final",
"List",
"<",
"GenericCompletionListener",
"<",
"?",
"extends",
"Future",
"<",
"T",
">",
">",
">",
"copy",
"=",
"new",
"ArrayList",
"<",
"GenericComp... | Notify all registered listeners with a special future on completion.
This method can be used if a different future should be used for
notification than the current one (for example if an enclosing future
is used, but the enclosed future should be notified on).
@param future the future to pass on to the listeners. | [
"Notify",
"all",
"registered",
"listeners",
"with",
"a",
"special",
"future",
"on",
"completion",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/internal/AbstractListenableFuture.java#L143-L154 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/internal/AbstractListenableFuture.java | AbstractListenableFuture.removeFromListeners | 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 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... | [
"protected",
"Future",
"<",
"T",
">",
"removeFromListeners",
"(",
"GenericCompletionListener",
"<",
"?",
"extends",
"Future",
"<",
"T",
">",
">",
"listener",
")",
"{",
"if",
"(",
"listener",
"==",
"null",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
... | Remove a listener from the list of registered listeners.
@param listener the listener to remove.
@return the current future to allow for chaining. | [
"Remove",
"a",
"listener",
"from",
"the",
"list",
"of",
"registered",
"listeners",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/internal/AbstractListenableFuture.java#L162-L174 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.registerMetrics | 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 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... | [
"protected",
"void",
"registerMetrics",
"(",
")",
"{",
"if",
"(",
"metricType",
".",
"equals",
"(",
"MetricType",
".",
"DEBUG",
")",
"||",
"metricType",
".",
"equals",
"(",
"MetricType",
".",
"PERFORMANCE",
")",
")",
"{",
"metrics",
".",
"addHistogram",
"(... | Register Metrics for collection.
Note that these Metrics may or may not take effect, depending on the
{@link MetricCollector} implementation. This can be controlled from
the {@link DefaultConnectionFactory}. | [
"Register",
"Metrics",
"for",
"collection",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L317-L334 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.createConnections | 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 | 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);
... | [
"protected",
"List",
"<",
"MemcachedNode",
">",
"createConnections",
"(",
"final",
"Collection",
"<",
"InetSocketAddress",
">",
"addrs",
")",
"throws",
"IOException",
"{",
"List",
"<",
"MemcachedNode",
">",
"connections",
"=",
"new",
"ArrayList",
"<",
"MemcachedNo... | Create connections for the given list of addresses.
@param addrs the list of addresses to connect to.
@return addrs list of {@link MemcachedNode}s.
@throws IOException if connecting was not successful. | [
"Create",
"connections",
"for",
"the",
"given",
"list",
"of",
"addresses",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L343-L379 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.selectorsMakeSense | 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 | 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... | [
"private",
"boolean",
"selectorsMakeSense",
"(",
")",
"{",
"for",
"(",
"MemcachedNode",
"qa",
":",
"locator",
".",
"getAll",
"(",
")",
")",
"{",
"if",
"(",
"qa",
".",
"getSk",
"(",
")",
"!=",
"null",
"&&",
"qa",
".",
"getSk",
"(",
")",
".",
"isVali... | Make sure that the current selectors make sense.
@return true if they do. | [
"Make",
"sure",
"that",
"the",
"current",
"selectors",
"make",
"sense",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L386-L412 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.handleIO | 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 | 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... | [
"public",
"void",
"handleIO",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"shutDown",
")",
"{",
"getLogger",
"(",
")",
".",
"debug",
"(",
"\"No IO while shut down.\"",
")",
";",
"return",
";",
"}",
"handleInputQueue",
"(",
")",
";",
"getLogger",
"("... | Handle all IO that flows through the connection.
This method is called in an endless loop, listens on NIO selectors and
dispatches the underlying read/write calls if needed. | [
"Handle",
"all",
"IO",
"that",
"flows",
"through",
"the",
"connection",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L420-L459 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.handleShutdownQueue | 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 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... | [
"private",
"void",
"handleShutdownQueue",
"(",
")",
"throws",
"IOException",
"{",
"for",
"(",
"MemcachedNode",
"qa",
":",
"nodesToShutdown",
")",
"{",
"if",
"(",
"!",
"addedQueue",
".",
"contains",
"(",
"qa",
")",
")",
"{",
"nodesToShutdown",
".",
"remove",
... | Check if nodes need to be shut down and do so if needed.
@throws IOException if the channel could not be closed properly. | [
"Check",
"if",
"nodes",
"need",
"to",
"be",
"shut",
"down",
"and",
"do",
"so",
"if",
"needed",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L528-L546 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.checkPotentiallyTimedOutConnection | 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 checkPotentiallyTimedOutConnection() {
boolean stillCheckingTimeouts = true;
while (stillCheckingTimeouts) {
try {
for (SelectionKey sk : selector.keys()) {
MemcachedNode mn = (MemcachedNode) sk.attachment();
if (mn.getContinuousTimeout() > timeoutExceptionThreshol... | [
"private",
"void",
"checkPotentiallyTimedOutConnection",
"(",
")",
"{",
"boolean",
"stillCheckingTimeouts",
"=",
"true",
";",
"while",
"(",
"stillCheckingTimeouts",
")",
"{",
"try",
"{",
"for",
"(",
"SelectionKey",
"sk",
":",
"selector",
".",
"keys",
"(",
")",
... | Check if one or more nodes exceeded the timeout Threshold. | [
"Check",
"if",
"one",
"or",
"more",
"nodes",
"exceeded",
"the",
"timeout",
"Threshold",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L551-L569 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.handleInputQueue | 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 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()) ... | [
"private",
"void",
"handleInputQueue",
"(",
")",
"{",
"if",
"(",
"!",
"addedQueue",
".",
"isEmpty",
"(",
")",
")",
"{",
"getLogger",
"(",
")",
".",
"debug",
"(",
"\"Handling queue\"",
")",
";",
"Collection",
"<",
"MemcachedNode",
">",
"toAdd",
"=",
"new"... | Handle any requests that have been made against the client. | [
"Handle",
"any",
"requests",
"that",
"have",
"been",
"made",
"against",
"the",
"client",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L574-L610 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.connected | 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 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);
}
} | [
"private",
"void",
"connected",
"(",
"final",
"MemcachedNode",
"node",
")",
"{",
"assert",
"node",
".",
"getChannel",
"(",
")",
".",
"isConnected",
"(",
")",
":",
"\"Not connected.\"",
";",
"int",
"rt",
"=",
"node",
".",
"getReconnectCount",
"(",
")",
";",... | Indicate a successful connect to the given node.
@param node the node which was successfully connected. | [
"Indicate",
"a",
"successful",
"connect",
"to",
"the",
"given",
"node",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L635-L643 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.lostConnection | private void lostConnection(final MemcachedNode node) {
queueReconnect(node);
for (ConnectionObserver observer : connObservers) {
observer.connectionLost(node.getSocketAddress());
}
} | java | private void lostConnection(final MemcachedNode node) {
queueReconnect(node);
for (ConnectionObserver observer : connObservers) {
observer.connectionLost(node.getSocketAddress());
}
} | [
"private",
"void",
"lostConnection",
"(",
"final",
"MemcachedNode",
"node",
")",
"{",
"queueReconnect",
"(",
"node",
")",
";",
"for",
"(",
"ConnectionObserver",
"observer",
":",
"connObservers",
")",
"{",
"observer",
".",
"connectionLost",
"(",
"node",
".",
"g... | Indicate a lost connection to the given node.
@param node the node where the connection was lost. | [
"Indicate",
"a",
"lost",
"connection",
"to",
"the",
"given",
"node",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L650-L655 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.belongsToCluster | boolean belongsToCluster(final MemcachedNode node) {
for (MemcachedNode n : locator.getAll()) {
if (n.getSocketAddress().equals(node.getSocketAddress())) {
return true;
}
}
return false;
} | java | boolean belongsToCluster(final MemcachedNode node) {
for (MemcachedNode n : locator.getAll()) {
if (n.getSocketAddress().equals(node.getSocketAddress())) {
return true;
}
}
return false;
} | [
"boolean",
"belongsToCluster",
"(",
"final",
"MemcachedNode",
"node",
")",
"{",
"for",
"(",
"MemcachedNode",
"n",
":",
"locator",
".",
"getAll",
"(",
")",
")",
"{",
"if",
"(",
"n",
".",
"getSocketAddress",
"(",
")",
".",
"equals",
"(",
"node",
".",
"ge... | Makes sure that the given node belongs to the current cluster.
Before trying to connect to a node, make sure it actually belongs to the
currently connected cluster. | [
"Makes",
"sure",
"that",
"the",
"given",
"node",
"belongs",
"to",
"the",
"current",
"cluster",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L663-L670 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.handleIO | 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 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... | [
"private",
"void",
"handleIO",
"(",
"final",
"SelectionKey",
"sk",
")",
"{",
"MemcachedNode",
"node",
"=",
"(",
"MemcachedNode",
")",
"sk",
".",
"attachment",
"(",
")",
";",
"try",
"{",
"getLogger",
"(",
")",
".",
"debug",
"(",
"\"Handling IO for: %s (r=%s,... | Handle IO for a specific selector.
Any IOException will cause a reconnect. Note that this code makes sure
that the corresponding node is not only able to connect, but also able to
respond in a correct fashion (if verifyAliveOnConnect is set to true
through a property). This is handled by issuing a dummy
version/noop c... | [
"Handle",
"IO",
"for",
"a",
"specific",
"selector",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L684-L723 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.finishConnect | 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 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);
... | [
"private",
"void",
"finishConnect",
"(",
"final",
"SelectionKey",
"sk",
",",
"final",
"MemcachedNode",
"node",
")",
"throws",
"IOException",
"{",
"if",
"(",
"verifyAliveOnConnect",
")",
"{",
"final",
"CountDownLatch",
"latch",
"=",
"new",
"CountDownLatch",
"(",
... | Finish the connect phase and potentially verify its liveness.
@param sk the selection key for the node.
@param node the actual node.
@throws IOException if something goes wrong during reading/writing. | [
"Finish",
"the",
"connect",
"phase",
"and",
"potentially",
"verify",
"its",
"liveness",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L749-L800 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.handleWrites | 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 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... | [
"private",
"void",
"handleWrites",
"(",
"final",
"MemcachedNode",
"node",
")",
"throws",
"IOException",
"{",
"node",
".",
"fillWriteBuffer",
"(",
"shouldOptimize",
")",
";",
"boolean",
"canWriteMore",
"=",
"node",
".",
"getBytesRemainingToWrite",
"(",
")",
">",
... | Handle pending writes for the given node.
@param node the node to handle writes for.
@throws IOException can be raised during writing failures. | [
"Handle",
"pending",
"writes",
"for",
"the",
"given",
"node",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L808-L817 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.handleReads | 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 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();... | [
"private",
"void",
"handleReads",
"(",
"final",
"MemcachedNode",
"node",
")",
"throws",
"IOException",
"{",
"Operation",
"currentOp",
"=",
"node",
".",
"getCurrentReadOp",
"(",
")",
";",
"if",
"(",
"currentOp",
"instanceof",
"TapAckOperationImpl",
")",
"{",
"nod... | Handle pending reads for the given node.
@param node the node to handle reads for.
@throws IOException can be raised during reading failures. | [
"Handle",
"pending",
"reads",
"for",
"the",
"given",
"node",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L825-L863 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.readBufferAndLogMetrics | 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 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... | [
"private",
"void",
"readBufferAndLogMetrics",
"(",
"final",
"Operation",
"currentOp",
",",
"final",
"ByteBuffer",
"rbuf",
",",
"final",
"MemcachedNode",
"node",
")",
"throws",
"IOException",
"{",
"currentOp",
".",
"readFromBuffer",
"(",
"rbuf",
")",
";",
"if",
"... | Read from the buffer and add metrics information.
@param currentOp the current operation to read.
@param rbuf the read buffer to read from.
@param node the node to read from.
@throws IOException if reading was not successful. | [
"Read",
"from",
"the",
"buffer",
"and",
"add",
"metrics",
"information",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L873-L901 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.handleReadsWhenChannelEndOfStream | 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 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... | [
"private",
"Operation",
"handleReadsWhenChannelEndOfStream",
"(",
"final",
"Operation",
"currentOp",
",",
"final",
"MemcachedNode",
"node",
",",
"final",
"ByteBuffer",
"rbuf",
")",
"throws",
"IOException",
"{",
"if",
"(",
"currentOp",
"instanceof",
"TapOperation",
")"... | Deal with an operation where the channel reached the end of a stream.
@param currentOp the current operation to read.
@param node the node for that operation.
@param rbuf the read buffer.
@return the next operation on the node to read.
@throws IOException if disconnect while reading. | [
"Deal",
"with",
"an",
"operation",
"where",
"the",
"channel",
"reached",
"the",
"end",
"of",
"a",
"stream",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L913-L927 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.potentiallyCloseLeakingChannel | 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 | 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);
}
}
... | [
"private",
"void",
"potentiallyCloseLeakingChannel",
"(",
"final",
"SocketChannel",
"ch",
",",
"final",
"MemcachedNode",
"node",
")",
"{",
"if",
"(",
"ch",
"!=",
"null",
"&&",
"!",
"ch",
".",
"isConnected",
"(",
")",
"&&",
"!",
"ch",
".",
"isConnectionPendin... | Make sure channel connections are not leaked and properly close under
faulty reconnect cirumstances.
@param ch the channel to potentially close.
@param node the node to which the channel should be bound to. | [
"Make",
"sure",
"channel",
"connections",
"are",
"not",
"leaked",
"and",
"properly",
"close",
"under",
"faulty",
"reconnect",
"cirumstances",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L1170-L1179 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.addOperation | 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 | 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();
... | [
"protected",
"void",
"addOperation",
"(",
"final",
"String",
"key",
",",
"final",
"Operation",
"o",
")",
"{",
"MemcachedNode",
"placeIn",
"=",
"null",
";",
"MemcachedNode",
"primary",
"=",
"locator",
".",
"getPrimary",
"(",
"key",
")",
";",
"if",
"(",
"pri... | Add an operation to a connection identified by the given key.
If the {@link MemcachedNode} is active or the {@link FailureMode} is set
to retry, the primary node will be used for that key. If the primary
node is not available and the {@link FailureMode} cancel is used, the
operation will be cancelled without further r... | [
"Add",
"an",
"operation",
"to",
"a",
"connection",
"identified",
"by",
"the",
"given",
"key",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L1217-L1248 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.insertOperation | 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 | 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... | [
"public",
"void",
"insertOperation",
"(",
"final",
"MemcachedNode",
"node",
",",
"final",
"Operation",
"o",
")",
"{",
"o",
".",
"setHandlingNode",
"(",
"node",
")",
";",
"o",
".",
"initialize",
"(",
")",
";",
"node",
".",
"insertOp",
"(",
"o",
")",
";"... | Insert an operation on the given node to the beginning of the queue.
@param node the node where to insert the {@link Operation}.
@param o the operation to insert. | [
"Insert",
"an",
"operation",
"on",
"the",
"given",
"node",
"to",
"the",
"beginning",
"of",
"the",
"queue",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L1256-L1266 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.addOperation | 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 | 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... | [
"protected",
"void",
"addOperation",
"(",
"final",
"MemcachedNode",
"node",
",",
"final",
"Operation",
"o",
")",
"{",
"if",
"(",
"!",
"node",
".",
"isAuthenticated",
"(",
")",
")",
"{",
"retryOperation",
"(",
"o",
")",
";",
"return",
";",
"}",
"o",
"."... | Enqueue an operation on the given node.
@param node the node where to enqueue the {@link Operation}.
@param o the operation to add. | [
"Enqueue",
"an",
"operation",
"on",
"the",
"given",
"node",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L1274-L1288 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.addOperations | public void addOperations(final Map<MemcachedNode, Operation> ops) {
for (Map.Entry<MemcachedNode, Operation> me : ops.entrySet()) {
addOperation(me.getKey(), me.getValue());
}
} | java | public void addOperations(final Map<MemcachedNode, Operation> ops) {
for (Map.Entry<MemcachedNode, Operation> me : ops.entrySet()) {
addOperation(me.getKey(), me.getValue());
}
} | [
"public",
"void",
"addOperations",
"(",
"final",
"Map",
"<",
"MemcachedNode",
",",
"Operation",
">",
"ops",
")",
"{",
"for",
"(",
"Map",
".",
"Entry",
"<",
"MemcachedNode",
",",
"Operation",
">",
"me",
":",
"ops",
".",
"entrySet",
"(",
")",
")",
"{",
... | Enqueue the given list of operations on each handling node.
@param ops the operations for each node. | [
"Enqueue",
"the",
"given",
"list",
"of",
"operations",
"on",
"each",
"handling",
"node",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L1295-L1299 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.broadcastOperation | 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 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... | [
"public",
"CountDownLatch",
"broadcastOperation",
"(",
"final",
"BroadcastOpFactory",
"of",
",",
"final",
"Collection",
"<",
"MemcachedNode",
">",
"nodes",
")",
"{",
"final",
"CountDownLatch",
"latch",
"=",
"new",
"CountDownLatch",
"(",
"nodes",
".",
"size",
"(",
... | Broadcast an operation to a collection of nodes.
@return a {@link CountDownLatch} that will be counted down when the
operations are complete. | [
"Broadcast",
"an",
"operation",
"to",
"a",
"collection",
"of",
"nodes",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L1317-L1334 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.shutdown | 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 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();
... | [
"public",
"void",
"shutdown",
"(",
")",
"throws",
"IOException",
"{",
"shutDown",
"=",
"true",
";",
"try",
"{",
"Selector",
"s",
"=",
"selector",
".",
"wakeup",
"(",
")",
";",
"assert",
"s",
"==",
"selector",
":",
"\"Wakeup returned the wrong selector.\"",
"... | Shut down all connections and do not accept further incoming ops. | [
"Shut",
"down",
"all",
"connections",
"and",
"do",
"not",
"accept",
"further",
"incoming",
"ops",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L1339-L1361 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.connectionsStatus | 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 | 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... | [
"public",
"String",
"connectionsStatus",
"(",
")",
"{",
"StringBuilder",
"connStatus",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"connStatus",
".",
"append",
"(",
"\"Connection Status {\"",
")",
";",
"for",
"(",
"MemcachedNode",
"node",
":",
"locator",
".",
... | Construct a String containing information about all nodes and their state.
@return a stringified representation of the connection status. | [
"Construct",
"a",
"String",
"containing",
"information",
"about",
"all",
"nodes",
"and",
"their",
"state",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L1379-L1395 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.setTimeout | 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 | 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... | [
"private",
"static",
"void",
"setTimeout",
"(",
"final",
"Operation",
"op",
",",
"final",
"boolean",
"isTimeout",
")",
"{",
"Logger",
"logger",
"=",
"LoggerFactory",
".",
"getLogger",
"(",
"MemcachedConnection",
".",
"class",
")",
";",
"try",
"{",
"if",
"(",... | Set the continuous timeout on an operation.
Ignore operations which have no handling nodes set yet (which may happen before nodes are properly
authenticated).
@param op the operation to use.
@param isTimeout is timed out or not. | [
"Set",
"the",
"continuous",
"timeout",
"on",
"an",
"operation",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L1424-L1439 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.run | @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 | @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... | [
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"while",
"(",
"running",
")",
"{",
"try",
"{",
"handleIO",
"(",
")",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"logRunException",
"(",
"e",
")",
";",
"}",
"catch",
"(",
"Cancelled... | Handle IO as long as the application is running. | [
"Handle",
"IO",
"as",
"long",
"as",
"the",
"application",
"is",
"running",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L1456-L1474 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.logRunException | private void logRunException(final Exception e) {
if (shutDown) {
getLogger().debug("Exception occurred during shutdown", e);
} else {
getLogger().warn("Problem handling memcached IO", e);
}
} | java | private void logRunException(final Exception e) {
if (shutDown) {
getLogger().debug("Exception occurred during shutdown", e);
} else {
getLogger().warn("Problem handling memcached IO", e);
}
} | [
"private",
"void",
"logRunException",
"(",
"final",
"Exception",
"e",
")",
"{",
"if",
"(",
"shutDown",
")",
"{",
"getLogger",
"(",
")",
".",
"debug",
"(",
"\"Exception occurred during shutdown\"",
",",
"e",
")",
";",
"}",
"else",
"{",
"getLogger",
"(",
")"... | Log a exception to different levels depending on the state.
Exceptions get logged at debug level when happening during shutdown, but
at warning level when operating normally.
@param e the exception to log. | [
"Log",
"a",
"exception",
"to",
"different",
"levels",
"depending",
"on",
"the",
"state",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L1484-L1490 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedConnection.java | MemcachedConnection.retryOperation | public void retryOperation(Operation op) {
if (retryQueueSize >= 0 && retryOps.size() >= retryQueueSize) {
if (!op.isCancelled()) {
op.cancel();
}
}
retryOps.add(op);
} | java | public void retryOperation(Operation op) {
if (retryQueueSize >= 0 && retryOps.size() >= retryQueueSize) {
if (!op.isCancelled()) {
op.cancel();
}
}
retryOps.add(op);
} | [
"public",
"void",
"retryOperation",
"(",
"Operation",
"op",
")",
"{",
"if",
"(",
"retryQueueSize",
">=",
"0",
"&&",
"retryOps",
".",
"size",
"(",
")",
">=",
"retryQueueSize",
")",
"{",
"if",
"(",
"!",
"op",
".",
"isCancelled",
"(",
")",
")",
"{",
"op... | Add a operation to the retry queue.
If the retry queue size is bounded and the size of the queue is reaching
that boundary, the operation is cancelled rather than added to the
retry queue.
@param op the operation to retry. | [
"Add",
"a",
"operation",
"to",
"the",
"retry",
"queue",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedConnection.java#L1510-L1517 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/transcoders/TranscodeService.java | TranscodeService.decode | 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 | 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);
... | [
"public",
"<",
"T",
">",
"Future",
"<",
"T",
">",
"decode",
"(",
"final",
"Transcoder",
"<",
"T",
">",
"tc",
",",
"final",
"CachedData",
"cachedData",
")",
"{",
"assert",
"!",
"pool",
".",
"isShutdown",
"(",
")",
":",
"\"Pool has already shut down.\"",
"... | Perform a decode. | [
"Perform",
"a",
"decode",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/transcoders/TranscodeService.java#L55-L71 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/tapmessage/ResponseMessage.java | ResponseMessage.deserialize | 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 | 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;
} | [
"private",
"Object",
"deserialize",
"(",
")",
"{",
"SerializingTranscoder",
"tc",
"=",
"new",
"SerializingTranscoder",
"(",
")",
";",
"CachedData",
"d",
"=",
"new",
"CachedData",
"(",
"this",
".",
"getItemFlags",
"(",
")",
",",
"this",
".",
"getValue",
"(",
... | Attempt to get the object represented by the given serialized bytes. | [
"Attempt",
"to",
"get",
"the",
"object",
"represented",
"by",
"the",
"given",
"serialized",
"bytes",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/tapmessage/ResponseMessage.java#L332-L339 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/compat/CloseUtil.java | CloseUtil.close | 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 void close(Closeable closeable) {
if (closeable != null) {
try {
closeable.close();
} catch (Exception e) {
logger.info("Unable to close %s", closeable, e);
}
}
} | [
"public",
"static",
"void",
"close",
"(",
"Closeable",
"closeable",
")",
"{",
"if",
"(",
"closeable",
"!=",
"null",
")",
"{",
"try",
"{",
"closeable",
".",
"close",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"logger",
".",
"info",
... | Close a closeable. | [
"Close",
"a",
"closeable",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/compat/CloseUtil.java#L48-L56 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/HashAlgorithmRegistry.java | HashAlgorithmRegistry.lookupHashAlgorithm | public static synchronized HashAlgorithm lookupHashAlgorithm(String name) {
validateName(name);
return REGISTRY.get(name.toLowerCase());
} | java | public static synchronized HashAlgorithm lookupHashAlgorithm(String name) {
validateName(name);
return REGISTRY.get(name.toLowerCase());
} | [
"public",
"static",
"synchronized",
"HashAlgorithm",
"lookupHashAlgorithm",
"(",
"String",
"name",
")",
"{",
"validateName",
"(",
"name",
")",
";",
"return",
"REGISTRY",
".",
"get",
"(",
"name",
".",
"toLowerCase",
"(",
")",
")",
";",
"}"
] | Tries to find selected hash algorithm using name provided.
<p>
Note, that lookup is being performed using name's lower-case value
@param name the algorithm name to be used for lookup
@return a {@link HashAlgorithm} instance or <code>null</code> if there's no
algorithm with the specified name | [
"Tries",
"to",
"find",
"selected",
"hash",
"algorithm",
"using",
"name",
"provided",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/HashAlgorithmRegistry.java#L81-L84 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedClient.java | MemcachedClient.getUnavailableServers | @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 Collection<SocketAddress> getUnavailableServers() {
ArrayList<SocketAddress> rv = new ArrayList<SocketAddress>();
for (MemcachedNode node : mconn.getLocator().getAll()) {
if (!node.isActive()) {
rv.add(node.getSocketAddress());
}
}
return rv;
} | [
"@",
"Override",
"public",
"Collection",
"<",
"SocketAddress",
">",
"getUnavailableServers",
"(",
")",
"{",
"ArrayList",
"<",
"SocketAddress",
">",
"rv",
"=",
"new",
"ArrayList",
"<",
"SocketAddress",
">",
"(",
")",
";",
"for",
"(",
"MemcachedNode",
"node",
... | Get the addresses of unavailable servers.
<p>
This is based on a snapshot in time so shouldn't be considered completely
accurate, but is a useful for getting a feel for what's working and what's
not working.
</p>
@return point-in-time view of currently available servers | [
"Get",
"the",
"addresses",
"of",
"unavailable",
"servers",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedClient.java#L252-L261 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedClient.java | MemcachedClient.touch | @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) {
return touch(key, exp, transcoder);
} | [
"@",
"Override",
"public",
"<",
"T",
">",
"OperationFuture",
"<",
"Boolean",
">",
"touch",
"(",
"final",
"String",
"key",
",",
"final",
"int",
"exp",
")",
"{",
"return",
"touch",
"(",
"key",
",",
"exp",
",",
"transcoder",
")",
";",
"}"
] | Touch the given key to reset its expiration time with the default
transcoder.
@param key the key to fetch
@param exp the new expiration to set for the given key
@return a future that will hold the return value of whether or not the
fetch succeeded
@throws IllegalStateException in the rare circumstance where queue is t... | [
"Touch",
"the",
"given",
"key",
"to",
"reset",
"its",
"expiration",
"time",
"with",
"the",
"default",
"transcoder",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedClient.java#L371-L374 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedClient.java | MemcachedClient.touch | @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 <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... | [
"@",
"Override",
"public",
"<",
"T",
">",
"OperationFuture",
"<",
"Boolean",
">",
"touch",
"(",
"final",
"String",
"key",
",",
"final",
"int",
"exp",
",",
"final",
"Transcoder",
"<",
"T",
">",
"tc",
")",
"{",
"final",
"CountDownLatch",
"latch",
"=",
"n... | Touch the given key to reset its expiration time.
@param key the key to fetch
@param exp the new expiration to set for the given key
@param tc the transcoder to serialize and unserialize value
@return a future that will hold the return value of whether or not the
fetch succeeded
@throws IllegalStateException in the ra... | [
"Touch",
"the",
"given",
"key",
"to",
"reset",
"its",
"expiration",
"time",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedClient.java#L387-L410 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedClient.java | MemcachedClient.asyncCAS | @Override
public OperationFuture<CASResponse>
asyncCAS(String key, long casId, Object value) {
return asyncCAS(key, casId, value, transcoder);
} | java | @Override
public OperationFuture<CASResponse>
asyncCAS(String key, long casId, Object value) {
return asyncCAS(key, casId, value, transcoder);
} | [
"@",
"Override",
"public",
"OperationFuture",
"<",
"CASResponse",
">",
"asyncCAS",
"(",
"String",
"key",
",",
"long",
"casId",
",",
"Object",
"value",
")",
"{",
"return",
"asyncCAS",
"(",
"key",
",",
"casId",
",",
"value",
",",
"transcoder",
")",
";",
"}... | Asynchronous CAS operation using the default transcoder.
@param key the key
@param casId the CAS identifier (from a gets operation)
@param value the new value
@return a future that will indicate the status of the CAS
@throws IllegalStateException in the rare circumstance where queue is too
full to accept any more requ... | [
"Asynchronous",
"CAS",
"operation",
"using",
"the",
"default",
"transcoder",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedClient.java#L667-L671 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedClient.java | MemcachedClient.cas | @Override
public CASResponse cas(String key, long casId, Object value) {
return cas(key, casId, value, transcoder);
} | java | @Override
public CASResponse cas(String key, long casId, Object value) {
return cas(key, casId, value, transcoder);
} | [
"@",
"Override",
"public",
"CASResponse",
"cas",
"(",
"String",
"key",
",",
"long",
"casId",
",",
"Object",
"value",
")",
"{",
"return",
"cas",
"(",
"key",
",",
"casId",
",",
"value",
",",
"transcoder",
")",
";",
"}"
] | Perform a synchronous CAS operation with the default transcoder.
@param key the key
@param casId the CAS identifier (from a gets operation)
@param value the new value
@return a CASResponse
@throws OperationTimeoutException if the global operation timeout is
exceeded
@throws IllegalStateException in the rare circumstan... | [
"Perform",
"a",
"synchronous",
"CAS",
"operation",
"with",
"the",
"default",
"transcoder",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedClient.java#L760-L763 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedClient.java | MemcachedClient.add | @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> OperationFuture<Boolean> add(String key, int exp, T o,
Transcoder<T> tc) {
return asyncStore(StoreType.add, key, exp, o, tc);
} | [
"@",
"Override",
"public",
"<",
"T",
">",
"OperationFuture",
"<",
"Boolean",
">",
"add",
"(",
"String",
"key",
",",
"int",
"exp",
",",
"T",
"o",
",",
"Transcoder",
"<",
"T",
">",
"tc",
")",
"{",
"return",
"asyncStore",
"(",
"StoreType",
".",
"add",
... | Add an object to the cache iff it does not exist already.
<p>
The {@code exp} value is passed along to memcached exactly as given,
and will be processed per the memcached protocol specification:
</p>
<p>
Note that the return will be false any time a mutation has not occurred.
</p>
<blockquote>
<p>
The actual value s... | [
"Add",
"an",
"object",
"to",
"the",
"cache",
"iff",
"it",
"does",
"not",
"exist",
"already",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedClient.java#L815-L819 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedClient.java | MemcachedClient.asyncGet | @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> 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... | [
"@",
"Override",
"public",
"<",
"T",
">",
"GetFuture",
"<",
"T",
">",
"asyncGet",
"(",
"final",
"String",
"key",
",",
"final",
"Transcoder",
"<",
"T",
">",
"tc",
")",
"{",
"final",
"CountDownLatch",
"latch",
"=",
"new",
"CountDownLatch",
"(",
"1",
")",... | Get the given key asynchronously.
@param <T>
@param key the key to fetch
@param tc the transcoder to serialize and unserialize value
@return a future that will hold the return value of the fetch
@throws IllegalStateException in the rare circumstance where queue is too
full to accept any more requests | [
"Get",
"the",
"given",
"key",
"asynchronously",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedClient.java#L1016-L1046 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedClient.java | MemcachedClient.getAndTouch | @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 <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 (... | [
"@",
"Override",
"public",
"<",
"T",
">",
"CASValue",
"<",
"T",
">",
"getAndTouch",
"(",
"String",
"key",
",",
"int",
"exp",
",",
"Transcoder",
"<",
"T",
">",
"tc",
")",
"{",
"try",
"{",
"return",
"asyncGetAndTouch",
"(",
"key",
",",
"exp",
",",
"t... | Get with a single key and reset its expiration.
@param <T>
@param key the key to get
@param exp the new expiration for the key
@param tc the transcoder to serialize and unserialize value
@return the result from the cache (null if there is none)
@throws OperationTimeoutException if the global operation timeout is
excee... | [
"Get",
"with",
"a",
"single",
"key",
"and",
"reset",
"its",
"expiration",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedClient.java#L1164-L1180 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedClient.java | MemcachedClient.getAndTouch | @Override
public CASValue<Object> getAndTouch(String key, int exp) {
return getAndTouch(key, exp, transcoder);
} | java | @Override
public CASValue<Object> getAndTouch(String key, int exp) {
return getAndTouch(key, exp, transcoder);
} | [
"@",
"Override",
"public",
"CASValue",
"<",
"Object",
">",
"getAndTouch",
"(",
"String",
"key",
",",
"int",
"exp",
")",
"{",
"return",
"getAndTouch",
"(",
"key",
",",
"exp",
",",
"transcoder",
")",
";",
"}"
] | Get a single key and reset its expiration using the default transcoder.
@param key the key to get
@param exp the new expiration for the key
@return the result from the cache and CAS id (null if there is none)
@throws OperationTimeoutException if the global operation timeout is
exceeded
@throws IllegalStateException in... | [
"Get",
"a",
"single",
"key",
"and",
"reset",
"its",
"expiration",
"using",
"the",
"default",
"transcoder",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedClient.java#L1193-L1196 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedClient.java | MemcachedClient.get | @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> 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... | [
"@",
"Override",
"public",
"<",
"T",
">",
"T",
"get",
"(",
"String",
"key",
",",
"Transcoder",
"<",
"T",
">",
"tc",
")",
"{",
"try",
"{",
"return",
"asyncGet",
"(",
"key",
",",
"tc",
")",
".",
"get",
"(",
"operationTimeout",
",",
"TimeUnit",
".",
... | Get with a single key.
@param <T>
@param key the key to get
@param tc the transcoder to serialize and unserialize value
@return the result from the cache (null if there is none)
@throws OperationTimeoutException if the global operation timeout is
exceeded
@throws CancellationException if operation was canceled
@throws... | [
"Get",
"with",
"a",
"single",
"key",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedClient.java#L1226-L1242 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedClient.java | MemcachedClient.asyncGetBulk | @Override
public <T> BulkFuture<Map<String, T>> asyncGetBulk(Transcoder<T> tc,
String... keys) {
return asyncGetBulk(Arrays.asList(keys), tc);
} | java | @Override
public <T> BulkFuture<Map<String, T>> asyncGetBulk(Transcoder<T> tc,
String... keys) {
return asyncGetBulk(Arrays.asList(keys), tc);
} | [
"@",
"Override",
"public",
"<",
"T",
">",
"BulkFuture",
"<",
"Map",
"<",
"String",
",",
"T",
">",
">",
"asyncGetBulk",
"(",
"Transcoder",
"<",
"T",
">",
"tc",
",",
"String",
"...",
"keys",
")",
"{",
"return",
"asyncGetBulk",
"(",
"Arrays",
".",
"asLi... | Varargs wrapper for asynchronous bulk gets.
@param <T>
@param tc the transcoder to serialize and unserialize value
@param keys one more more keys to get
@return the future values of those keys
@throws IllegalStateException in the rare circumstance where queue is too
full to accept any more requests | [
"Varargs",
"wrapper",
"for",
"asynchronous",
"bulk",
"gets",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedClient.java#L1459-L1463 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedClient.java | MemcachedClient.asyncGetBulk | @Override
public BulkFuture<Map<String, Object>> asyncGetBulk(String... keys) {
return asyncGetBulk(Arrays.asList(keys), transcoder);
} | java | @Override
public BulkFuture<Map<String, Object>> asyncGetBulk(String... keys) {
return asyncGetBulk(Arrays.asList(keys), transcoder);
} | [
"@",
"Override",
"public",
"BulkFuture",
"<",
"Map",
"<",
"String",
",",
"Object",
">",
">",
"asyncGetBulk",
"(",
"String",
"...",
"keys",
")",
"{",
"return",
"asyncGetBulk",
"(",
"Arrays",
".",
"asList",
"(",
"keys",
")",
",",
"transcoder",
")",
";",
... | Varargs wrapper for asynchronous bulk gets with the default transcoder.
@param keys one more more keys to get
@return the future values of those keys
@throws IllegalStateException in the rare circumstance where queue is too
full to accept any more requests | [
"Varargs",
"wrapper",
"for",
"asynchronous",
"bulk",
"gets",
"with",
"the",
"default",
"transcoder",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedClient.java#L1473-L1476 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedClient.java | MemcachedClient.asyncGetAndTouch | @Override
public OperationFuture<CASValue<Object>> asyncGetAndTouch(final String key,
final int exp) {
return asyncGetAndTouch(key, exp, transcoder);
} | java | @Override
public OperationFuture<CASValue<Object>> asyncGetAndTouch(final String key,
final int exp) {
return asyncGetAndTouch(key, exp, transcoder);
} | [
"@",
"Override",
"public",
"OperationFuture",
"<",
"CASValue",
"<",
"Object",
">",
">",
"asyncGetAndTouch",
"(",
"final",
"String",
"key",
",",
"final",
"int",
"exp",
")",
"{",
"return",
"asyncGetAndTouch",
"(",
"key",
",",
"exp",
",",
"transcoder",
")",
"... | Get the given key to reset its expiration time.
@param key the key to fetch
@param exp the new expiration to set for the given key
@return a future that will hold the return value of the fetch
@throws IllegalStateException in the rare circumstance where queue is too
full to accept any more requests | [
"Get",
"the",
"given",
"key",
"to",
"reset",
"its",
"expiration",
"time",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedClient.java#L1487-L1491 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedClient.java | MemcachedClient.getVersions | @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, 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... | [
"@",
"Override",
"public",
"Map",
"<",
"SocketAddress",
",",
"String",
">",
"getVersions",
"(",
")",
"{",
"final",
"Map",
"<",
"SocketAddress",
",",
"String",
">",
"rv",
"=",
"new",
"ConcurrentHashMap",
"<",
"SocketAddress",
",",
"String",
">",
"(",
")",
... | Get the versions of all of the connected memcacheds.
@return a Map of SocketAddress to String for connected servers
@throws IllegalStateException in the rare circumstance where queue is too
full to accept any more requests | [
"Get",
"the",
"versions",
"of",
"all",
"of",
"the",
"connected",
"memcacheds",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedClient.java#L1658-L1687 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedClient.java | MemcachedClient.getStats | @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 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... | [
"@",
"Override",
"public",
"Map",
"<",
"SocketAddress",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
"getStats",
"(",
"final",
"String",
"arg",
")",
"{",
"final",
"Map",
"<",
"SocketAddress",
",",
"Map",
"<",
"String",
",",
"String",
">",
">",
... | Get a set of stats from all connections.
@param arg which stats to get
@return a Map of the server SocketAddress to a map of String stat keys to
String stat values.
@throws IllegalStateException in the rare circumstance where queue is too
full to accept any more requests | [
"Get",
"a",
"set",
"of",
"stats",
"from",
"all",
"connections",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedClient.java#L1710-L1748 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedClient.java | MemcachedClient.incr | @Override
public long incr(String key, int by) {
return mutate(Mutator.incr, key, by, 0, -1);
} | java | @Override
public long incr(String key, int by) {
return mutate(Mutator.incr, key, by, 0, -1);
} | [
"@",
"Override",
"public",
"long",
"incr",
"(",
"String",
"key",
",",
"int",
"by",
")",
"{",
"return",
"mutate",
"(",
"Mutator",
".",
"incr",
",",
"key",
",",
"by",
",",
"0",
",",
"-",
"1",
")",
";",
"}"
] | Increment the given key by the given amount.
Due to the way the memcached server operates on items, incremented and
decremented items will be returned as Strings with any operations that
return a value.
@param key the key
@param by the amount to increment
@return the new value (-1 if the key doesn't exist)
@throws Op... | [
"Increment",
"the",
"given",
"key",
"by",
"the",
"given",
"amount",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedClient.java#L1815-L1818 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedClient.java | MemcachedClient.decr | @Override
public long decr(String key, long by) {
return mutate(Mutator.decr, key, by, 0, -1);
} | java | @Override
public long decr(String key, long by) {
return mutate(Mutator.decr, key, by, 0, -1);
} | [
"@",
"Override",
"public",
"long",
"decr",
"(",
"String",
"key",
",",
"long",
"by",
")",
"{",
"return",
"mutate",
"(",
"Mutator",
".",
"decr",
",",
"key",
",",
"by",
",",
"0",
",",
"-",
"1",
")",
";",
"}"
] | Decrement the given key by the given value.
Due to the way the memcached server operates on items, incremented and
decremented items will be returned as Strings with any operations that
return a value.
@param key the key
@param by the value
@return the new value (-1 if the key doesn't exist)
@throws OperationTimeoutE... | [
"Decrement",
"the",
"given",
"key",
"by",
"the",
"given",
"value",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedClient.java#L1835-L1838 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedClient.java | MemcachedClient.asyncDecr | @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> asyncDecr(String key, int by, long def,
int exp) {
return asyncMutate(Mutator.decr, key, by, def, exp);
} | [
"@",
"Override",
"public",
"OperationFuture",
"<",
"Long",
">",
"asyncDecr",
"(",
"String",
"key",
",",
"int",
"by",
",",
"long",
"def",
",",
"int",
"exp",
")",
"{",
"return",
"asyncMutate",
"(",
"Mutator",
".",
"decr",
",",
"key",
",",
"by",
",",
"d... | Asynchronous decrement.
@param key key to decrement
@param by the amount to decrement the value by
@param def the default value (if the counter does not exist)
@param exp the expiration of this object
@return a future with the decremented value, or -1 if the decrement failed.
@throws IllegalStateException in the rare ... | [
"Asynchronous",
"decrement",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedClient.java#L2127-L2131 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedClient.java | MemcachedClient.asyncIncr | @Override
public OperationFuture<Long> asyncIncr(String key, long by, long def) {
return asyncMutate(Mutator.incr, key, by, def, 0);
} | java | @Override
public OperationFuture<Long> asyncIncr(String key, long by, long def) {
return asyncMutate(Mutator.incr, key, by, def, 0);
} | [
"@",
"Override",
"public",
"OperationFuture",
"<",
"Long",
">",
"asyncIncr",
"(",
"String",
"key",
",",
"long",
"by",
",",
"long",
"def",
")",
"{",
"return",
"asyncMutate",
"(",
"Mutator",
".",
"incr",
",",
"key",
",",
"by",
",",
"def",
",",
"0",
")"... | Asychronous increment.
@param key key to increment
@param by the amount to increment the value by
@param def the default value (if the counter does not exist)
@return a future with the incremented value, or -1 if the increment failed.
@throws IllegalStateException in the rare circumstance where queue is too
full to ac... | [
"Asychronous",
"increment",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedClient.java#L2143-L2146 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedClient.java | MemcachedClient.incr | @Override
public long incr(String key, long by, long def) {
return mutateWithDefault(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);
} | [
"@",
"Override",
"public",
"long",
"incr",
"(",
"String",
"key",
",",
"long",
"by",
",",
"long",
"def",
")",
"{",
"return",
"mutateWithDefault",
"(",
"Mutator",
".",
"incr",
",",
"key",
",",
"by",
",",
"def",
",",
"0",
")",
";",
"}"
] | Increment the given counter, returning the new value.
@param key the key
@param by the amount to increment
@param def the default value (if the counter does not exist)
@return the new value, or -1 if we were unable to increment or add
@throws OperationTimeoutException if the global operation timeout is
exceeded
@throw... | [
"Increment",
"the",
"given",
"counter",
"returning",
"the",
"new",
"value",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedClient.java#L2205-L2208 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedClient.java | MemcachedClient.delete | @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> 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... | [
"@",
"Override",
"public",
"OperationFuture",
"<",
"Boolean",
">",
"delete",
"(",
"String",
"key",
",",
"long",
"cas",
")",
"{",
"final",
"CountDownLatch",
"latch",
"=",
"new",
"CountDownLatch",
"(",
"1",
")",
";",
"final",
"OperationFuture",
"<",
"Boolean",... | Delete the given key from the cache of the given CAS value applies.
@param key the key to delete
@param cas the CAS value to apply.
@return whether or not the operation was performed
@throws IllegalStateException in the rare circumstance where queue is too
full to accept any more requests | [
"Delete",
"the",
"given",
"key",
"from",
"the",
"cache",
"of",
"the",
"given",
"CAS",
"value",
"applies",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedClient.java#L2307-L2341 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedClient.java | MemcachedClient.flush | @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 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... | [
"@",
"Override",
"public",
"OperationFuture",
"<",
"Boolean",
">",
"flush",
"(",
"final",
"int",
"delay",
")",
"{",
"final",
"AtomicReference",
"<",
"Boolean",
">",
"flushResult",
"=",
"new",
"AtomicReference",
"<",
"Boolean",
">",
"(",
"null",
")",
";",
"... | Flush all caches from all servers with a delay of application.
@param delay the period of time to delay, in seconds
@return whether or not the operation was accepted
@throws IllegalStateException in the rare circumstance where queue is too
full to accept any more requests | [
"Flush",
"all",
"caches",
"from",
"all",
"servers",
"with",
"a",
"delay",
"of",
"application",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedClient.java#L2351-L2422 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/MemcachedClient.java | MemcachedClient.waitForQueues | @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 | @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
... | [
"@",
"Override",
"public",
"boolean",
"waitForQueues",
"(",
"long",
"timeout",
",",
"TimeUnit",
"unit",
")",
"{",
"CountDownLatch",
"blatch",
"=",
"broadcastOp",
"(",
"new",
"BroadcastOpFactory",
"(",
")",
"{",
"@",
"Override",
"public",
"Operation",
"newOp",
... | Wait for the queues to die down.
@param timeout the amount of time time for shutdown
@param unit the TimeUnit for the timeout
@return result of the request for the wait
@throws IllegalStateException in the rare circumstance where queue is too
full to accept any more requests | [
"Wait",
"for",
"the",
"queues",
"to",
"die",
"down",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/MemcachedClient.java#L2533-L2560 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/ConnectionFactoryBuilder.java | ConnectionFactoryBuilder.setProtocol | 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 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;
} | [
"public",
"ConnectionFactoryBuilder",
"setProtocol",
"(",
"Protocol",
"prot",
")",
"{",
"switch",
"(",
"prot",
")",
"{",
"case",
"TEXT",
":",
"opFact",
"=",
"new",
"AsciiOperationFactory",
"(",
")",
";",
"break",
";",
"case",
"BINARY",
":",
"opFact",
"=",
... | Convenience method to specify the protocol to use. | [
"Convenience",
"method",
"to",
"specify",
"the",
"protocol",
"to",
"use",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/ConnectionFactoryBuilder.java#L234-L246 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/CASMutator.java | CASMutator.cas | 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 | 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... | [
"public",
"T",
"cas",
"(",
"final",
"String",
"key",
",",
"final",
"T",
"initial",
",",
"int",
"initialExp",
",",
"final",
"CASMutation",
"<",
"T",
">",
"m",
")",
"throws",
"Exception",
"{",
"T",
"rv",
"=",
"initial",
";",
"boolean",
"done",
"=",
"fa... | CAS a new value in for a key.
<p>
Note that if initial is null, this method will only update existing values.
</p>
@param key the key to be CASed
@param initial the value to use when the object is not cached
@param initialExp the expiration time to use when initializing
@param m the mutation to perform on an object i... | [
"CAS",
"a",
"new",
"value",
"in",
"for",
"a",
"key",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/CASMutator.java#L101-L149 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/compat/SyncThread.java | SyncThread.run | @Override
public void run() {
try {
barrier.await();
rv = callable.call();
} catch (Throwable t) {
throwable = t;
}
latch.countDown();
} | java | @Override
public void run() {
try {
barrier.await();
rv = callable.call();
} catch (Throwable t) {
throwable = t;
}
latch.countDown();
} | [
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"barrier",
".",
"await",
"(",
")",
";",
"rv",
"=",
"callable",
".",
"call",
"(",
")",
";",
"}",
"catch",
"(",
"Throwable",
"t",
")",
"{",
"throwable",
"=",
"t",
";",
"}",
"lat... | Wait for the barrier, invoke the callable and capture the result or an
exception. | [
"Wait",
"for",
"the",
"barrier",
"invoke",
"the",
"callable",
"and",
"capture",
"the",
"result",
"or",
"an",
"exception",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/compat/SyncThread.java#L63-L72 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/compat/SyncThread.java | SyncThread.getCompletedThreads | 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> 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>... | [
"public",
"static",
"<",
"T",
">",
"Collection",
"<",
"SyncThread",
"<",
"T",
">",
">",
"getCompletedThreads",
"(",
"int",
"num",
",",
"Callable",
"<",
"T",
">",
"callable",
")",
"throws",
"InterruptedException",
"{",
"Collection",
"<",
"SyncThread",
"<",
... | Get a collection of SyncThreads that all began as close to the same time as
possible and have all completed.
@param <T> the result type of the SyncThread
@param num the number of concurrent threads to execute
@param callable the thing to call
@return the completed SyncThreads
@throws InterruptedException if we're inte... | [
"Get",
"a",
"collection",
"of",
"SyncThreads",
"that",
"all",
"began",
"as",
"close",
"to",
"the",
"same",
"time",
"as",
"possible",
"and",
"have",
"all",
"completed",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/compat/SyncThread.java#L98-L112 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/compat/SyncThread.java | SyncThread.getDistinctResultCount | 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 | 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... | [
"public",
"static",
"<",
"T",
">",
"int",
"getDistinctResultCount",
"(",
"int",
"num",
",",
"Callable",
"<",
"T",
">",
"callable",
")",
"throws",
"Throwable",
"{",
"IdentityHashMap",
"<",
"T",
",",
"Object",
">",
"found",
"=",
"new",
"IdentityHashMap",
"<"... | Get the distinct result count for the given callable at the given
concurrency.
@param <T> the type of the callable
@param num the concurrency
@param callable the callable to invoke
@return the number of distinct (by identity) results found
@throws Throwable if an exception occurred in one of the invocations | [
"Get",
"the",
"distinct",
"result",
"count",
"for",
"the",
"given",
"callable",
"at",
"the",
"given",
"concurrency",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/compat/SyncThread.java#L124-L132 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/compat/log/Log4JLogger.java | Log4JLogger.log | @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 | @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... | [
"@",
"Override",
"public",
"void",
"log",
"(",
"Level",
"level",
",",
"Object",
"message",
",",
"Throwable",
"e",
")",
"{",
"org",
".",
"apache",
".",
"log4j",
".",
"Level",
"pLevel",
"=",
"org",
".",
"apache",
".",
"log4j",
".",
"Level",
".",
"DEBUG... | Wrapper around log4j.
@param level net.spy.compat.log.Level level.
@param message object message
@param e optional throwable | [
"Wrapper",
"around",
"log4j",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/compat/log/Log4JLogger.java#L70-L100 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/transcoders/BaseSerializingTranscoder.java | BaseSerializingTranscoder.decodeString | 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 | 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;
} | [
"protected",
"String",
"decodeString",
"(",
"byte",
"[",
"]",
"data",
")",
"{",
"String",
"rv",
"=",
"null",
";",
"try",
"{",
"if",
"(",
"data",
"!=",
"null",
")",
"{",
"rv",
"=",
"new",
"String",
"(",
"data",
",",
"charset",
")",
";",
"}",
"}",
... | Decode the string with the current character set. | [
"Decode",
"the",
"string",
"with",
"the",
"current",
"character",
"set",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/transcoders/BaseSerializingTranscoder.java#L203-L213 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/util/CacheLoader.java | CacheLoader.loadData | 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(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... | [
"public",
"<",
"T",
">",
"Future",
"<",
"?",
">",
"loadData",
"(",
"Iterator",
"<",
"Map",
".",
"Entry",
"<",
"String",
",",
"T",
">",
">",
"i",
")",
"{",
"Future",
"<",
"Boolean",
">",
"mostRecent",
"=",
"null",
";",
"while",
"(",
"i",
".",
"h... | Load data from the given iterator.
@param <T> type of data being loaded
@param i the iterator of data to load | [
"Load",
"data",
"from",
"the",
"given",
"iterator",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/util/CacheLoader.java#L79-L88 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/util/CacheLoader.java | CacheLoader.loadData | public <T> Future<?> loadData(Map<String, T> map) {
return loadData(map.entrySet().iterator());
} | java | public <T> Future<?> loadData(Map<String, T> map) {
return loadData(map.entrySet().iterator());
} | [
"public",
"<",
"T",
">",
"Future",
"<",
"?",
">",
"loadData",
"(",
"Map",
"<",
"String",
",",
"T",
">",
"map",
")",
"{",
"return",
"loadData",
"(",
"map",
".",
"entrySet",
"(",
")",
".",
"iterator",
"(",
")",
")",
";",
"}"
] | Load data from the given map.
@param <T> type of data being loaded
@param map the map of keys to values that needs to be loaded | [
"Load",
"data",
"from",
"the",
"given",
"map",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/util/CacheLoader.java#L96-L98 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/util/CacheLoader.java | CacheLoader.push | 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 | 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) ... | [
"public",
"<",
"T",
">",
"Future",
"<",
"Boolean",
">",
"push",
"(",
"String",
"k",
",",
"T",
"value",
")",
"{",
"Future",
"<",
"Boolean",
">",
"rv",
"=",
"null",
";",
"while",
"(",
"rv",
"==",
"null",
")",
"{",
"try",
"{",
"rv",
"=",
"client",... | Push a value into the cache.
This is a wrapper around set that throttles and retries on full queues.
@param <T> the type being stored
@param k the key
@param value the value
@return the future representing the stored data | [
"Push",
"a",
"value",
"into",
"the",
"cache",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/util/CacheLoader.java#L110-L133 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/compat/log/SunLogger.java | SunLogger.log | @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 | @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... | [
"@",
"Override",
"public",
"void",
"log",
"(",
"Level",
"level",
",",
"Object",
"message",
",",
"Throwable",
"e",
")",
"{",
"java",
".",
"util",
".",
"logging",
".",
"Level",
"sLevel",
"=",
"java",
".",
"util",
".",
"logging",
".",
"Level",
".",
"SEV... | Wrapper around sun logger.
@param level net.spy.compat.log.AbstractLogger level.
@param message object message
@param e optional throwable | [
"Wrapper",
"around",
"sun",
"logger",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/compat/log/SunLogger.java#L73-L137 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/util/StringUtils.java | StringUtils.join | 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 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... | [
"public",
"static",
"String",
"join",
"(",
"final",
"Collection",
"<",
"String",
">",
"chunks",
",",
"final",
"String",
"delimiter",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"!",
"chunks",
".",
"isEmpty",
"(... | Join a collection of strings together into one.
@param chunks the chunks to join.
@param delimiter the delimiter between the keys.
@return the fully joined string. | [
"Join",
"a",
"collection",
"of",
"strings",
"together",
"into",
"one",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/util/StringUtils.java#L82-L94 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/util/StringUtils.java | StringUtils.isJsonObject | 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 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... | [
"public",
"static",
"boolean",
"isJsonObject",
"(",
"final",
"String",
"s",
")",
"{",
"if",
"(",
"s",
"==",
"null",
"||",
"s",
".",
"isEmpty",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"s",
".",
"startsWith",
"(",
"\"{\"",
")",
... | Check if a given string is a JSON object.
@param s the input string.
@return true if it is a JSON object, false otherwise. | [
"Check",
"if",
"a",
"given",
"string",
"is",
"a",
"JSON",
"object",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/util/StringUtils.java#L102-L114 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/util/StringUtils.java | StringUtils.validateKey | 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 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... | [
"public",
"static",
"void",
"validateKey",
"(",
"final",
"String",
"key",
",",
"final",
"boolean",
"binary",
")",
"{",
"byte",
"[",
"]",
"keyBytes",
"=",
"KeyUtil",
".",
"getKeyBytes",
"(",
"key",
")",
";",
"int",
"keyLength",
"=",
"keyBytes",
".",
"leng... | Check if a given key is valid to transmit.
@param key the key to check.
@param binary if binary protocol is used. | [
"Check",
"if",
"a",
"given",
"key",
"is",
"valid",
"to",
"transmit",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/util/StringUtils.java#L122-L143 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/KetamaNodeKeyFormatter.java | KetamaNodeKeyFormatter.getKeyForNode | 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 | 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'... | [
"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 co... | Returns a uniquely identifying key, suitable for hashing by the
KetamaNodeLocator algorithm.
@param node The MemcachedNode to use to form the unique identifier
@param repetition The repetition number for the particular node in question
(0 is the first repetition)
@return The key that represents the specific repetition... | [
"Returns",
"a",
"uniquely",
"identifying",
"key",
"suitable",
"for",
"hashing",
"by",
"the",
"KetamaNodeLocator",
"algorithm",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/KetamaNodeKeyFormatter.java#L105-L137 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/protocol/ascii/OperationImpl.java | OperationImpl.matchStatus | 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 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... | [
"protected",
"final",
"OperationStatus",
"matchStatus",
"(",
"String",
"line",
",",
"OperationStatus",
"...",
"statii",
")",
"{",
"OperationStatus",
"rv",
"=",
"null",
";",
"for",
"(",
"OperationStatus",
"status",
":",
"statii",
")",
"{",
"if",
"(",
"line",
... | Match the status line provided against one of the given OperationStatus
objects. If none match, return a failure status with the given line.
@param line the current line
@param statii several status objects
@return the appropriate status object | [
"Match",
"the",
"status",
"line",
"provided",
"against",
"one",
"of",
"the",
"given",
"OperationStatus",
"objects",
".",
"If",
"none",
"match",
"return",
"a",
"failure",
"status",
"with",
"the",
"given",
"line",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/protocol/ascii/OperationImpl.java#L66-L78 | train |
dustin/java-memcached-client | src/main/java/net/spy/memcached/protocol/ascii/OperationImpl.java | OperationImpl.setArguments | 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 | 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);
} | [
"protected",
"final",
"void",
"setArguments",
"(",
"ByteBuffer",
"bb",
",",
"Object",
"...",
"args",
")",
"{",
"boolean",
"wasFirst",
"=",
"true",
";",
"for",
"(",
"Object",
"o",
":",
"args",
")",
"{",
"if",
"(",
"wasFirst",
")",
"{",
"wasFirst",
"=",
... | Set some arguments for an operation into the given byte buffer. | [
"Set",
"some",
"arguments",
"for",
"an",
"operation",
"into",
"the",
"given",
"byte",
"buffer",
"."
] | c232307ad8e0c7ccc926e495dd7d5aad2d713318 | https://github.com/dustin/java-memcached-client/blob/c232307ad8e0c7ccc926e495dd7d5aad2d713318/src/main/java/net/spy/memcached/protocol/ascii/OperationImpl.java#L99-L110 | train |
Sefford/CircularProgressDrawable | circular-progress-drawable-sample/src/main/java/com/sefford/circularprogressdrawable/sample/MainActivity.java | MainActivity.preparePressedAnimation | private Animator preparePressedAnimation() {
Animator animation = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.CIRCLE_SCALE_PROPERTY,
drawable.getCircleScale(), 0.65f);
animation.setDuration(120);
return animation;
} | java | private Animator preparePressedAnimation() {
Animator animation = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.CIRCLE_SCALE_PROPERTY,
drawable.getCircleScale(), 0.65f);
animation.setDuration(120);
return animation;
} | [
"private",
"Animator",
"preparePressedAnimation",
"(",
")",
"{",
"Animator",
"animation",
"=",
"ObjectAnimator",
".",
"ofFloat",
"(",
"drawable",
",",
"CircularProgressDrawable",
".",
"CIRCLE_SCALE_PROPERTY",
",",
"drawable",
".",
"getCircleScale",
"(",
")",
",",
"0... | This animation was intended to keep a pressed state of the Drawable
@return Animation | [
"This",
"animation",
"was",
"intended",
"to",
"keep",
"a",
"pressed",
"state",
"of",
"the",
"Drawable"
] | b068f15f710a3e7c7afafa22c55ca642799e613d | https://github.com/Sefford/CircularProgressDrawable/blob/b068f15f710a3e7c7afafa22c55ca642799e613d/circular-progress-drawable-sample/src/main/java/com/sefford/circularprogressdrawable/sample/MainActivity.java#L117-L122 | train |
Sefford/CircularProgressDrawable | circular-progress-drawable-sample/src/main/java/com/sefford/circularprogressdrawable/sample/MainActivity.java | MainActivity.preparePulseAnimation | 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 preparePulseAnimation() {
AnimatorSet animation = new AnimatorSet();
Animator firstBounce = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.CIRCLE_SCALE_PROPERTY,
drawable.getCircleScale(), 0.88f);
firstBounce.setDuration(300);
firstBounce.setI... | [
"private",
"Animator",
"preparePulseAnimation",
"(",
")",
"{",
"AnimatorSet",
"animation",
"=",
"new",
"AnimatorSet",
"(",
")",
";",
"Animator",
"firstBounce",
"=",
"ObjectAnimator",
".",
"ofFloat",
"(",
"drawable",
",",
"CircularProgressDrawable",
".",
"CIRCLE_SCAL... | This animation will make a pulse effect to the inner circle
@return Animation | [
"This",
"animation",
"will",
"make",
"a",
"pulse",
"effect",
"to",
"the",
"inner",
"circle"
] | b068f15f710a3e7c7afafa22c55ca642799e613d | https://github.com/Sefford/CircularProgressDrawable/blob/b068f15f710a3e7c7afafa22c55ca642799e613d/circular-progress-drawable-sample/src/main/java/com/sefford/circularprogressdrawable/sample/MainActivity.java#L129-L147 | train |
Sefford/CircularProgressDrawable | circular-progress-drawable-sample/src/main/java/com/sefford/circularprogressdrawable/sample/MainActivity.java | MainActivity.prepareStyle1Animation | 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 prepareStyle1Animation() {
AnimatorSet animation = new AnimatorSet();
final Animator indeterminateAnimation = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.PROGRESS_PROPERTY, 0, 3600);
indeterminateAnimation.setDuration(3600);
Animator innerCircleAnimation ... | [
"private",
"Animator",
"prepareStyle1Animation",
"(",
")",
"{",
"AnimatorSet",
"animation",
"=",
"new",
"AnimatorSet",
"(",
")",
";",
"final",
"Animator",
"indeterminateAnimation",
"=",
"ObjectAnimator",
".",
"ofFloat",
"(",
"drawable",
",",
"CircularProgressDrawable"... | Style 1 animation will simulate a indeterminate loading while taking advantage of the inner
circle to provide a progress sense
@return Animation | [
"Style",
"1",
"animation",
"will",
"simulate",
"a",
"indeterminate",
"loading",
"while",
"taking",
"advantage",
"of",
"the",
"inner",
"circle",
"to",
"provide",
"a",
"progress",
"sense"
] | b068f15f710a3e7c7afafa22c55ca642799e613d | https://github.com/Sefford/CircularProgressDrawable/blob/b068f15f710a3e7c7afafa22c55ca642799e613d/circular-progress-drawable-sample/src/main/java/com/sefford/circularprogressdrawable/sample/MainActivity.java#L155-L179 | train |
Sefford/CircularProgressDrawable | circular-progress-drawable-sample/src/main/java/com/sefford/circularprogressdrawable/sample/MainActivity.java | MainActivity.prepareStyle2Animation | private Animator prepareStyle2Animation() {
AnimatorSet animation = new AnimatorSet();
ObjectAnimator progressAnimation = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.PROGRESS_PROPERTY,
0f, 1f);
progressAnimation.setDuration(3600);
progressAnimation.setInter... | java | private Animator prepareStyle2Animation() {
AnimatorSet animation = new AnimatorSet();
ObjectAnimator progressAnimation = ObjectAnimator.ofFloat(drawable, CircularProgressDrawable.PROGRESS_PROPERTY,
0f, 1f);
progressAnimation.setDuration(3600);
progressAnimation.setInter... | [
"private",
"Animator",
"prepareStyle2Animation",
"(",
")",
"{",
"AnimatorSet",
"animation",
"=",
"new",
"AnimatorSet",
"(",
")",
";",
"ObjectAnimator",
"progressAnimation",
"=",
"ObjectAnimator",
".",
"ofFloat",
"(",
"drawable",
",",
"CircularProgressDrawable",
".",
... | Style 2 animation will fill the outer ring while applying a color effect from red to green
@return Animation | [
"Style",
"2",
"animation",
"will",
"fill",
"the",
"outer",
"ring",
"while",
"applying",
"a",
"color",
"effect",
"from",
"red",
"to",
"green"
] | b068f15f710a3e7c7afafa22c55ca642799e613d | https://github.com/Sefford/CircularProgressDrawable/blob/b068f15f710a3e7c7afafa22c55ca642799e613d/circular-progress-drawable-sample/src/main/java/com/sefford/circularprogressdrawable/sample/MainActivity.java#L186-L202 | train |
prestodb/presto-hadoop-apache2 | src/main/java/org/apache/hadoop/util/LineReader.java | LineReader.readDefaultLine | 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 | 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... | [
"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\n * already buffered in buffer, so we have several cases... | Read a line terminated by one of CR, LF, or CRLF. | [
"Read",
"a",
"line",
"terminated",
"by",
"one",
"of",
"CR",
"LF",
"or",
"CRLF",
"."
] | 6c848073a47b777f47561255e467c954ec24e2f9 | https://github.com/prestodb/presto-hadoop-apache2/blob/6c848073a47b777f47561255e467c954ec24e2f9/src/main/java/org/apache/hadoop/util/LineReader.java#L206-L287 | train |
blackducksoftware/blackduck-common | src/main/java/com/synopsys/integration/blackduck/codelocation/signaturescanner/command/ScannerZipInstaller.java | ScannerZipInstaller.installOrUpdateScanner | 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 void installOrUpdateScanner(File installDirectory) throws BlackDuckIntegrationException {
File scannerExpansionDirectory = new File(installDirectory, ScannerZipInstaller.BLACK_DUCK_SIGNATURE_SCANNER_INSTALL_DIRECTORY);
scannerExpansionDirectory.mkdirs();
File versionFile = null;
... | [
"public",
"void",
"installOrUpdateScanner",
"(",
"File",
"installDirectory",
")",
"throws",
"BlackDuckIntegrationException",
"{",
"File",
"scannerExpansionDirectory",
"=",
"new",
"File",
"(",
"installDirectory",
",",
"ScannerZipInstaller",
".",
"BLACK_DUCK_SIGNATURE_SCANNER_I... | The Black Duck Signature Scanner will be download if it has not
previously been downloaded or if it has been updated on the server. The
absolute path to the install location will be returned if it was
downloaded or found successfully, otherwise an Optional.empty will be
returned and the log will contain details concern... | [
"The",
"Black",
"Duck",
"Signature",
"Scanner",
"will",
"be",
"download",
"if",
"it",
"has",
"not",
"previously",
"been",
"downloaded",
"or",
"if",
"it",
"has",
"been",
"updated",
"on",
"the",
"server",
".",
"The",
"absolute",
"path",
"to",
"the",
"install... | 4ea4e90b52b75470b71c597b65cf4e2d73887bcc | https://github.com/blackducksoftware/blackduck-common/blob/4ea4e90b52b75470b71c597b65cf4e2d73887bcc/src/main/java/com/synopsys/integration/blackduck/codelocation/signaturescanner/command/ScannerZipInstaller.java#L100-L119 | train |
blackducksoftware/blackduck-common | src/main/java/com/synopsys/integration/blackduck/codelocation/signaturescanner/ScanBatch.java | ScanBatch.createScanCommands | public List<ScanCommand> createScanCommands(final File defaultInstallDirectory, final ScanPathsUtility scanPathsUtility, final IntEnvironmentVariables intEnvironmentVariables) throws BlackDuckIntegrationException {
String scanCliOptsToUse = scanCliOpts;
if (null != intEnvironmentVariables && StringUtils... | java | public List<ScanCommand> createScanCommands(final File defaultInstallDirectory, final ScanPathsUtility scanPathsUtility, final IntEnvironmentVariables intEnvironmentVariables) throws BlackDuckIntegrationException {
String scanCliOptsToUse = scanCliOpts;
if (null != intEnvironmentVariables && StringUtils... | [
"public",
"List",
"<",
"ScanCommand",
">",
"createScanCommands",
"(",
"final",
"File",
"defaultInstallDirectory",
",",
"final",
"ScanPathsUtility",
"scanPathsUtility",
",",
"final",
"IntEnvironmentVariables",
"intEnvironmentVariables",
")",
"throws",
"BlackDuckIntegrationExce... | The default install directory will be used if the batch does not already have an install directory. | [
"The",
"default",
"install",
"directory",
"will",
"be",
"used",
"if",
"the",
"batch",
"does",
"not",
"already",
"have",
"an",
"install",
"directory",
"."
] | 4ea4e90b52b75470b71c597b65cf4e2d73887bcc | https://github.com/blackducksoftware/blackduck-common/blob/4ea4e90b52b75470b71c597b65cf4e2d73887bcc/src/main/java/com/synopsys/integration/blackduck/codelocation/signaturescanner/ScanBatch.java#L97-L145 | train |
blackducksoftware/blackduck-common | src/main/java/com/synopsys/integration/blackduck/codelocation/signaturescanner/command/ScanCommandCallable.java | ScanCommandCallable.createPrintableCommand | 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 | 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
... | [
"private",
"String",
"createPrintableCommand",
"(",
"final",
"List",
"<",
"String",
">",
"cmd",
")",
"{",
"final",
"List",
"<",
"String",
">",
"cmdToOutput",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"cmdToOutput",
".",
"addAll",
"(",
"cmd",
")",
";"... | Code to mask passwords in the logs | [
"Code",
"to",
"mask",
"passwords",
"in",
"the",
"logs"
] | 4ea4e90b52b75470b71c597b65cf4e2d73887bcc | https://github.com/blackducksoftware/blackduck-common/blob/4ea4e90b52b75470b71c597b65cf4e2d73887bcc/src/main/java/com/synopsys/integration/blackduck/codelocation/signaturescanner/command/ScanCommandCallable.java#L142-L164 | train |
blackducksoftware/blackduck-common | src/main/java/com/synopsys/integration/blackduck/service/ProjectMappingService.java | ProjectMappingService.populateApplicationId | 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 void populateApplicationId(ProjectView projectView, String applicationId) throws IntegrationException {
List<ProjectMappingView> projectMappings = blackDuckService.getAllResponses(projectView, ProjectView.PROJECT_MAPPINGS_LINK_RESPONSE);
boolean canCreate = projectMappings.isEmpty();
if (... | [
"public",
"void",
"populateApplicationId",
"(",
"ProjectView",
"projectView",
",",
"String",
"applicationId",
")",
"throws",
"IntegrationException",
"{",
"List",
"<",
"ProjectMappingView",
">",
"projectMappings",
"=",
"blackDuckService",
".",
"getAllResponses",
"(",
"pr... | Sets the applicationId for a project
@throws IntegrationException | [
"Sets",
"the",
"applicationId",
"for",
"a",
"project"
] | 4ea4e90b52b75470b71c597b65cf4e2d73887bcc | https://github.com/blackducksoftware/blackduck-common/blob/4ea4e90b52b75470b71c597b65cf4e2d73887bcc/src/main/java/com/synopsys/integration/blackduck/service/ProjectMappingService.java#L42-L60 | train |
blackducksoftware/blackduck-common | src/main/java/com/synopsys/integration/blackduck/service/ReportService.java | ReportService.generateBlackDuckNoticesReport | 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 String generateBlackDuckNoticesReport(ProjectVersionView version, ReportFormatType reportFormat) throws InterruptedException, IntegrationException {
if (version.hasLink(ProjectVersionView.LICENSEREPORTS_LINK)) {
try {
logger.debug("Starting the Notices Report generation.");
... | [
"public",
"String",
"generateBlackDuckNoticesReport",
"(",
"ProjectVersionView",
"version",
",",
"ReportFormatType",
"reportFormat",
")",
"throws",
"InterruptedException",
",",
"IntegrationException",
"{",
"if",
"(",
"version",
".",
"hasLink",
"(",
"ProjectVersionView",
"... | Assumes the BOM has already been updated | [
"Assumes",
"the",
"BOM",
"has",
"already",
"been",
"updated"
] | 4ea4e90b52b75470b71c597b65cf4e2d73887bcc | https://github.com/blackducksoftware/blackduck-common/blob/4ea4e90b52b75470b71c597b65cf4e2d73887bcc/src/main/java/com/synopsys/integration/blackduck/service/ReportService.java#L293-L326 | train |
blackducksoftware/blackduck-common | src/main/java/com/synopsys/integration/blackduck/service/ReportService.java | ReportService.isReportFinishedGenerating | 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 ReportView isReportFinishedGenerating(String reportUri) throws InterruptedException, IntegrationException {
long startTime = System.currentTimeMillis();
long elapsedTime = 0;
Date timeFinished = null;
ReportView reportInfo = null;
while (timeFinished == null) {
... | [
"public",
"ReportView",
"isReportFinishedGenerating",
"(",
"String",
"reportUri",
")",
"throws",
"InterruptedException",
",",
"IntegrationException",
"{",
"long",
"startTime",
"=",
"System",
".",
"currentTimeMillis",
"(",
")",
";",
"long",
"elapsedTime",
"=",
"0",
"... | Checks the report URL every 5 seconds until the report has a finished time available, then we know it is done being generated. Throws BlackDuckIntegrationException after 30 minutes if the report has not been generated yet. | [
"Checks",
"the",
"report",
"URL",
"every",
"5",
"seconds",
"until",
"the",
"report",
"has",
"a",
"finished",
"time",
"available",
"then",
"we",
"know",
"it",
"is",
"done",
"being",
"generated",
".",
"Throws",
"BlackDuckIntegrationException",
"after",
"30",
"mi... | 4ea4e90b52b75470b71c597b65cf4e2d73887bcc | https://github.com/blackducksoftware/blackduck-common/blob/4ea4e90b52b75470b71c597b65cf4e2d73887bcc/src/main/java/com/synopsys/integration/blackduck/service/ReportService.java#L343-L364 | train |
blackducksoftware/blackduck-common | src/main/java/com/synopsys/integration/blackduck/service/ProjectUsersService.java | ProjectUsersService.getAllActiveUsersForProject | public Set<UserView> getAllActiveUsersForProject(ProjectView projectView) throws IntegrationException {
Set<UserView> users = new HashSet<>();
List<AssignedUserGroupView> assignedGroups = getAssignedGroupsToProject(projectView);
for (AssignedUserGroupView assignedUserGroupView : assignedGroups)... | java | public Set<UserView> getAllActiveUsersForProject(ProjectView projectView) throws IntegrationException {
Set<UserView> users = new HashSet<>();
List<AssignedUserGroupView> assignedGroups = getAssignedGroupsToProject(projectView);
for (AssignedUserGroupView assignedUserGroupView : assignedGroups)... | [
"public",
"Set",
"<",
"UserView",
">",
"getAllActiveUsersForProject",
"(",
"ProjectView",
"projectView",
")",
"throws",
"IntegrationException",
"{",
"Set",
"<",
"UserView",
">",
"users",
"=",
"new",
"HashSet",
"<>",
"(",
")",
";",
"List",
"<",
"AssignedUserGroup... | This will get all explicitly assigned users for a project, as well as all users who are assigned to groups that are explicitly assigned to a project. | [
"This",
"will",
"get",
"all",
"explicitly",
"assigned",
"users",
"for",
"a",
"project",
"as",
"well",
"as",
"all",
"users",
"who",
"are",
"assigned",
"to",
"groups",
"that",
"are",
"explicitly",
"assigned",
"to",
"a",
"project",
"."
] | 4ea4e90b52b75470b71c597b65cf4e2d73887bcc | https://github.com/blackducksoftware/blackduck-common/blob/4ea4e90b52b75470b71c597b65cf4e2d73887bcc/src/main/java/com/synopsys/integration/blackduck/service/ProjectUsersService.java#L91-L115 | train |
blackducksoftware/blackduck-common | src/main/java/com/synopsys/integration/blackduck/service/PolicyRuleService.java | PolicyRuleService.createPolicyRuleForExternalId | public String createPolicyRuleForExternalId(ComponentService componentService, ExternalId externalId, String policyName) throws IntegrationException {
Optional<ComponentVersionView> componentVersionView = componentService.getComponentVersion(externalId);
if (!componentVersionView.isPresent()) {
... | java | public String createPolicyRuleForExternalId(ComponentService componentService, ExternalId externalId, String policyName) throws IntegrationException {
Optional<ComponentVersionView> componentVersionView = componentService.getComponentVersion(externalId);
if (!componentVersionView.isPresent()) {
... | [
"public",
"String",
"createPolicyRuleForExternalId",
"(",
"ComponentService",
"componentService",
",",
"ExternalId",
"externalId",
",",
"String",
"policyName",
")",
"throws",
"IntegrationException",
"{",
"Optional",
"<",
"ComponentVersionView",
">",
"componentVersionView",
... | This will create a policy rule that will be violated by the existence of a matching external id in the project's BOM. | [
"This",
"will",
"create",
"a",
"policy",
"rule",
"that",
"will",
"be",
"violated",
"by",
"the",
"existence",
"of",
"a",
"matching",
"external",
"id",
"in",
"the",
"project",
"s",
"BOM",
"."
] | 4ea4e90b52b75470b71c597b65cf4e2d73887bcc | https://github.com/blackducksoftware/blackduck-common/blob/4ea4e90b52b75470b71c597b65cf4e2d73887bcc/src/main/java/com/synopsys/integration/blackduck/service/PolicyRuleService.java#L62-L79 | train |
apache/reef | lang/java/reef-common/src/main/java/org/apache/reef/util/OSUtils.java | OSUtils.kill | 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 | 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:... | [
"public",
"static",
"void",
"kill",
"(",
"final",
"long",
"pid",
")",
"throws",
"IOException",
",",
"InterruptedException",
"{",
"if",
"(",
"isUnix",
"(",
")",
")",
"{",
"final",
"Process",
"process",
"=",
"new",
"ProcessBuilder",
"(",
")",
".",
"command",... | Kill the process.
@param pid Process id
@throws IOException | [
"Kill",
"the",
"process",
"."
] | e2c47121cde21108a602c560cf76565a40d0e916 | https://github.com/apache/reef/blob/e2c47121cde21108a602c560cf76565a40d0e916/lang/java/reef-common/src/main/java/org/apache/reef/util/OSUtils.java#L126-L142 | train |
apache/reef | lang/java/reef-common/src/main/java/org/apache/reef/runtime/common/utils/DispatchingEStage.java | DispatchingEStage.register | @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("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));
} | [
"@",
"SuppressWarnings",
"(",
"\"checkstyle:hiddenfield\"",
")",
"public",
"<",
"T",
",",
"U",
"extends",
"T",
">",
"void",
"register",
"(",
"final",
"Class",
"<",
"T",
">",
"type",
",",
"final",
"Set",
"<",
"EventHandler",
"<",
"U",
">",
">",
"handlers"... | Register a new event handler.
@param type Message type to process with this handler.
@param handlers A set of handlers that process that type of message.
@param <T> Message type.
@param <U> Type of message that event handler supports. Must be a subclass of T. | [
"Register",
"a",
"new",
"event",
"handler",
"."
] | e2c47121cde21108a602c560cf76565a40d0e916 | https://github.com/apache/reef/blob/e2c47121cde21108a602c560cf76565a40d0e916/lang/java/reef-common/src/main/java/org/apache/reef/runtime/common/utils/DispatchingEStage.java#L97-L101 | train |
apache/reef | lang/java/reef-common/src/main/java/org/apache/reef/runtime/common/utils/DispatchingEStage.java | DispatchingEStage.onNext | @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 | @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... | [
"@",
"SuppressWarnings",
"(",
"\"unchecked\"",
")",
"public",
"<",
"T",
",",
"U",
"extends",
"T",
">",
"void",
"onNext",
"(",
"final",
"Class",
"<",
"T",
">",
"type",
",",
"final",
"U",
"message",
")",
"{",
"if",
"(",
"this",
".",
"isClosed",
"(",
... | Dispatch a new message by type.
If the stage is already closed, log a warning and ignore the message.
@param type Type of event handler - must match the register() call.
@param message A message to process. Must be a subclass of T.
@param <T> Message type that event handler supports.
@param <U> input message... | [
"Dispatch",
"a",
"new",
"message",
"by",
"type",
".",
"If",
"the",
"stage",
"is",
"already",
"closed",
"log",
"a",
"warning",
"and",
"ignore",
"the",
"message",
"."
] | e2c47121cde21108a602c560cf76565a40d0e916 | https://github.com/apache/reef/blob/e2c47121cde21108a602c560cf76565a40d0e916/lang/java/reef-common/src/main/java/org/apache/reef/runtime/common/utils/DispatchingEStage.java#L111-L120 | train |
apache/reef | lang/java/reef-io/src/main/java/org/apache/reef/io/network/naming/NameLookupClient.java | NameLookupClient.lookup | @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 | @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... | [
"@",
"Override",
"public",
"InetSocketAddress",
"lookup",
"(",
"final",
"Identifier",
"id",
")",
"throws",
"Exception",
"{",
"return",
"cache",
".",
"get",
"(",
"id",
",",
"new",
"Callable",
"<",
"InetSocketAddress",
">",
"(",
")",
"{",
"@",
"Override",
"p... | Finds an address for an identifier.
@param id an identifier
@return an Internet socket address | [
"Finds",
"an",
"address",
"for",
"an",
"identifier",
"."
] | e2c47121cde21108a602c560cf76565a40d0e916 | https://github.com/apache/reef/blob/e2c47121cde21108a602c560cf76565a40d0e916/lang/java/reef-io/src/main/java/org/apache/reef/io/network/naming/NameLookupClient.java#L147-L177 | train |
apache/reef | lang/java/reef-io/src/main/java/org/apache/reef/io/network/naming/NameLookupClient.java | NameLookupClient.remoteLookup | 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 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... | [
"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"... | Retrieves an address for an identifier remotely.
@param id an identifier
@return an Internet socket address
@throws Exception | [
"Retrieves",
"an",
"address",
"for",
"an",
"identifier",
"remotely",
"."
] | e2c47121cde21108a602c560cf76565a40d0e916 | https://github.com/apache/reef/blob/e2c47121cde21108a602c560cf76565a40d0e916/lang/java/reef-io/src/main/java/org/apache/reef/io/network/naming/NameLookupClient.java#L186-L218 | train |
apache/reef | lang/java/reef-applications/reef-vortex/src/main/java/org/apache/reef/vortex/evaluator/AggregateContainer.java | AggregateContainer.scheduleTasklet | 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 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... | [
"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",
"(",
"!",
... | Schedule aggregation tasks on a Timer. Creates a new timer schedule for triggering the aggregation function
if this is the first time the aggregation function has tasklets scheduled on it.
Adds the Tasklet to pending Tasklets. | [
"Schedule",
"aggregation",
"tasks",
"on",
"a",
"Timer",
".",
"Creates",
"a",
"new",
"timer",
"schedule",
"for",
"triggering",
"the",
"aggregation",
"function",
"if",
"this",
"is",
"the",
"first",
"time",
"the",
"aggregation",
"function",
"has",
"tasklets",
"sc... | e2c47121cde21108a602c560cf76565a40d0e916 | https://github.com/apache/reef/blob/e2c47121cde21108a602c560cf76565a40d0e916/lang/java/reef-applications/reef-vortex/src/main/java/org/apache/reef/vortex/evaluator/AggregateContainer.java#L149-L180 | train |
apache/reef | lang/java/reef-applications/reef-vortex/src/main/java/org/apache/reef/vortex/evaluator/AggregateContainer.java | AggregateContainer.taskletComplete | 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 taskletComplete(final int taskletId, final Object result) {
final boolean aggregateOnCount;
synchronized (stateLock) {
completedTasklets.add(new ImmutablePair<>(taskletId, result));
removePendingTaskletReferenceCount(taskletId);
aggregateOnCount = aggregateOnCount();
}
if ... | [
"public",
"void",
"taskletComplete",
"(",
"final",
"int",
"taskletId",
",",
"final",
"Object",
"result",
")",
"{",
"final",
"boolean",
"aggregateOnCount",
";",
"synchronized",
"(",
"stateLock",
")",
"{",
"completedTasklets",
".",
"add",
"(",
"new",
"ImmutablePai... | Reported when an associated tasklet is complete and adds it to the completion pool. | [
"Reported",
"when",
"an",
"associated",
"tasklet",
"is",
"complete",
"and",
"adds",
"it",
"to",
"the",
"completion",
"pool",
"."
] | e2c47121cde21108a602c560cf76565a40d0e916 | https://github.com/apache/reef/blob/e2c47121cde21108a602c560cf76565a40d0e916/lang/java/reef-applications/reef-vortex/src/main/java/org/apache/reef/vortex/evaluator/AggregateContainer.java#L185-L196 | train |
apache/reef | lang/java/reef-applications/reef-vortex/src/main/java/org/apache/reef/vortex/evaluator/AggregateContainer.java | AggregateContainer.taskletFailed | 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 | 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... | [
"public",
"void",
"taskletFailed",
"(",
"final",
"int",
"taskletId",
",",
"final",
"Exception",
"e",
")",
"{",
"final",
"boolean",
"aggregateOnCount",
";",
"synchronized",
"(",
"stateLock",
")",
"{",
"failedTasklets",
".",
"add",
"(",
"new",
"ImmutablePair",
"... | Reported when an associated tasklet is complete and adds it to the failure pool. | [
"Reported",
"when",
"an",
"associated",
"tasklet",
"is",
"complete",
"and",
"adds",
"it",
"to",
"the",
"failure",
"pool",
"."
] | e2c47121cde21108a602c560cf76565a40d0e916 | https://github.com/apache/reef/blob/e2c47121cde21108a602c560cf76565a40d0e916/lang/java/reef-applications/reef-vortex/src/main/java/org/apache/reef/vortex/evaluator/AggregateContainer.java#L201-L212 | train |
apache/reef | lang/java/reef-applications/reef-vortex/src/main/java/org/apache/reef/vortex/driver/PendingTaskletLauncher.java | PendingTaskletLauncher.onNext | @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 | @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... | [
"@",
"Override",
"public",
"void",
"onNext",
"(",
"final",
"Integer",
"integer",
")",
"{",
"while",
"(",
"!",
"runningWorkers",
".",
"isTerminated",
"(",
")",
")",
"{",
"try",
"{",
"final",
"Tasklet",
"tasklet",
"=",
"pendingTasklets",
".",
"takeFirst",
"(... | Repeatedly take a tasklet from the pending queue and launch it via RunningWorkers. | [
"Repeatedly",
"take",
"a",
"tasklet",
"from",
"the",
"pending",
"queue",
"and",
"launch",
"it",
"via",
"RunningWorkers",
"."
] | e2c47121cde21108a602c560cf76565a40d0e916 | https://github.com/apache/reef/blob/e2c47121cde21108a602c560cf76565a40d0e916/lang/java/reef-applications/reef-vortex/src/main/java/org/apache/reef/vortex/driver/PendingTaskletLauncher.java#L48-L58 | train |
apache/reef | lang/java/reef-runtime-yarn/src/main/java/org/apache/reef/runtime/yarn/client/unmanaged/UnmanagedAmYarnJobSubmissionHandler.java | UnmanagedAmYarnJobSubmissionHandler.getQueue | 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 | private String getQueue(final JobSubmissionEvent jobSubmissionEvent) {
try {
return Tang.Factory.getTang().newInjector(
jobSubmissionEvent.getConfiguration()).getNamedInstance(JobQueue.class);
} catch (final InjectionException e) {
return this.defaultQueueName;
}
} | [
"private",
"String",
"getQueue",
"(",
"final",
"JobSubmissionEvent",
"jobSubmissionEvent",
")",
"{",
"try",
"{",
"return",
"Tang",
".",
"Factory",
".",
"getTang",
"(",
")",
".",
"newInjector",
"(",
"jobSubmissionEvent",
".",
"getConfiguration",
"(",
")",
")",
... | Extract the queue name from the jobSubmissionEvent or return default if none is set. | [
"Extract",
"the",
"queue",
"name",
"from",
"the",
"jobSubmissionEvent",
"or",
"return",
"default",
"if",
"none",
"is",
"set",
"."
] | e2c47121cde21108a602c560cf76565a40d0e916 | https://github.com/apache/reef/blob/e2c47121cde21108a602c560cf76565a40d0e916/lang/java/reef-runtime-yarn/src/main/java/org/apache/reef/runtime/yarn/client/unmanaged/UnmanagedAmYarnJobSubmissionHandler.java#L110-L117 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.