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
Stratio/stratio-cassandra
src/java/org/apache/cassandra/db/context/CounterContext.java
CounterContext.total
public long total(ByteBuffer context) { long total = 0L; // we could use a ContextState but it is easy enough that we avoid the object creation for (int offset = context.position() + headerLength(context); offset < context.limit(); offset += STEP_LENGTH) total += context.getLong(offset + CounterId.LENGTH + CLOCK_LENGTH); return total; }
java
public long total(ByteBuffer context) { long total = 0L; // we could use a ContextState but it is easy enough that we avoid the object creation for (int offset = context.position() + headerLength(context); offset < context.limit(); offset += STEP_LENGTH) total += context.getLong(offset + CounterId.LENGTH + CLOCK_LENGTH); return total; }
[ "public", "long", "total", "(", "ByteBuffer", "context", ")", "{", "long", "total", "=", "0L", ";", "// we could use a ContextState but it is easy enough that we avoid the object creation", "for", "(", "int", "offset", "=", "context", ".", "position", "(", ")", "+", ...
Returns the aggregated count across all counter ids. @param context a counter context @return the aggregated count represented by {@code context}
[ "Returns", "the", "aggregated", "count", "across", "all", "counter", "ids", "." ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/context/CounterContext.java#L533-L540
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/auth/Resources.java
Resources.chain
public static List<? extends IResource> chain(IResource resource) { List<IResource> chain = new ArrayList<IResource>(); while (true) { chain.add(resource); if (!resource.hasParent()) break; resource = resource.getParent(); } return chain; }
java
public static List<? extends IResource> chain(IResource resource) { List<IResource> chain = new ArrayList<IResource>(); while (true) { chain.add(resource); if (!resource.hasParent()) break; resource = resource.getParent(); } return chain; }
[ "public", "static", "List", "<", "?", "extends", "IResource", ">", "chain", "(", "IResource", "resource", ")", "{", "List", "<", "IResource", ">", "chain", "=", "new", "ArrayList", "<", "IResource", ">", "(", ")", ";", "while", "(", "true", ")", "{", ...
Construct a chain of resource parents starting with the resource and ending with the root. @param resource The staring point. @return list of resource in the chain form start to the root.
[ "Construct", "a", "chain", "of", "resource", "parents", "starting", "with", "the", "resource", "and", "ending", "with", "the", "root", "." ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/auth/Resources.java#L33-L44
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/gms/FailureDetector.java
FailureDetector.dumpInterArrivalTimes
public void dumpInterArrivalTimes() { File file = FileUtils.createTempFile("failuredetector-", ".dat"); OutputStream os = null; try { os = new BufferedOutputStream(new FileOutputStream(file, true)); os.write(toString().getBytes()); } catch (IOException e) { throw new FSWriteError(e, file); } finally { FileUtils.closeQuietly(os); } }
java
public void dumpInterArrivalTimes() { File file = FileUtils.createTempFile("failuredetector-", ".dat"); OutputStream os = null; try { os = new BufferedOutputStream(new FileOutputStream(file, true)); os.write(toString().getBytes()); } catch (IOException e) { throw new FSWriteError(e, file); } finally { FileUtils.closeQuietly(os); } }
[ "public", "void", "dumpInterArrivalTimes", "(", ")", "{", "File", "file", "=", "FileUtils", ".", "createTempFile", "(", "\"failuredetector-\"", ",", "\".dat\"", ")", ";", "OutputStream", "os", "=", "null", ";", "try", "{", "os", "=", "new", "BufferedOutputStre...
Dump the inter arrival times for examination if necessary.
[ "Dump", "the", "inter", "arrival", "times", "for", "examination", "if", "necessary", "." ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/gms/FailureDetector.java#L160-L178
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/gms/FailureDetector.java
ArrivalWindow.phi
double phi(long tnow) { assert arrivalIntervals.size() > 0 && tLast > 0; // should not be called before any samples arrive long t = tnow - tLast; return t / mean(); }
java
double phi(long tnow) { assert arrivalIntervals.size() > 0 && tLast > 0; // should not be called before any samples arrive long t = tnow - tLast; return t / mean(); }
[ "double", "phi", "(", "long", "tnow", ")", "{", "assert", "arrivalIntervals", ".", "size", "(", ")", ">", "0", "&&", "tLast", ">", "0", ";", "// should not be called before any samples arrive", "long", "t", "=", "tnow", "-", "tLast", ";", "return", "t", "/...
see CASSANDRA-2597 for an explanation of the math at work here.
[ "see", "CASSANDRA", "-", "2597", "for", "an", "explanation", "of", "the", "math", "at", "work", "here", "." ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/gms/FailureDetector.java#L356-L361
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/utils/obs/BitUtil.java
BitUtil.pop
public static int pop(long x) { /* Hacker's Delight 32 bit pop function: * http://www.hackersdelight.org/HDcode/newCode/pop_arrayHS.cc * int pop(unsigned x) { x = x - ((x >> 1) & 0x55555555); x = (x & 0x33333333) + ((x >> 2) & 0x33333333); x = (x + (x >> 4)) & 0x0F0F0F0F; x = x + (x >> 8); x = x + (x >> 16); return x & 0x0000003F; } ***/ // 64 bit java version of the C function from above x = x - ((x >>> 1) & 0x5555555555555555L); x = (x & 0x3333333333333333L) + ((x >>>2 ) & 0x3333333333333333L); x = (x + (x >>> 4)) & 0x0F0F0F0F0F0F0F0FL; x = x + (x >>> 8); x = x + (x >>> 16); x = x + (x >>> 32); return ((int)x) & 0x7F; }
java
public static int pop(long x) { /* Hacker's Delight 32 bit pop function: * http://www.hackersdelight.org/HDcode/newCode/pop_arrayHS.cc * int pop(unsigned x) { x = x - ((x >> 1) & 0x55555555); x = (x & 0x33333333) + ((x >> 2) & 0x33333333); x = (x + (x >> 4)) & 0x0F0F0F0F; x = x + (x >> 8); x = x + (x >> 16); return x & 0x0000003F; } ***/ // 64 bit java version of the C function from above x = x - ((x >>> 1) & 0x5555555555555555L); x = (x & 0x3333333333333333L) + ((x >>>2 ) & 0x3333333333333333L); x = (x + (x >>> 4)) & 0x0F0F0F0F0F0F0F0FL; x = x + (x >>> 8); x = x + (x >>> 16); x = x + (x >>> 32); return ((int)x) & 0x7F; }
[ "public", "static", "int", "pop", "(", "long", "x", ")", "{", "/* Hacker's Delight 32 bit pop function:\n * http://www.hackersdelight.org/HDcode/newCode/pop_arrayHS.cc\n *\n int pop(unsigned x) {\n x = x - ((x >> 1) & 0x55555555);\n x = (x & 0x33333333) + ((x >> 2) & 0x33333333);\n ...
Returns the number of bits set in the long
[ "Returns", "the", "number", "of", "bits", "set", "in", "the", "long" ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/utils/obs/BitUtil.java#L26-L48
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/utils/obs/BitUtil.java
BitUtil.ntz
public static int ntz(long val) { // A full binary search to determine the low byte was slower than // a linear search for nextSetBit(). This is most likely because // the implementation of nextSetBit() shifts bits to the right, increasing // the probability that the first non-zero byte is in the rhs. // // This implementation does a single binary search at the top level only // so that all other bit shifting can be done on ints instead of longs to // remain friendly to 32 bit architectures. In addition, the case of a // non-zero first byte is checked for first because it is the most common // in dense bit arrays. int lower = (int)val; int lowByte = lower & 0xff; if (lowByte != 0) return ntzTable[lowByte]; if (lower!=0) { lowByte = (lower>>>8) & 0xff; if (lowByte != 0) return ntzTable[lowByte] + 8; lowByte = (lower>>>16) & 0xff; if (lowByte != 0) return ntzTable[lowByte] + 16; // no need to mask off low byte for the last byte in the 32 bit word // no need to check for zero on the last byte either. return ntzTable[lower>>>24] + 24; } else { // grab upper 32 bits int upper=(int)(val>>32); lowByte = upper & 0xff; if (lowByte != 0) return ntzTable[lowByte] + 32; lowByte = (upper>>>8) & 0xff; if (lowByte != 0) return ntzTable[lowByte] + 40; lowByte = (upper>>>16) & 0xff; if (lowByte != 0) return ntzTable[lowByte] + 48; // no need to mask off low byte for the last byte in the 32 bit word // no need to check for zero on the last byte either. return ntzTable[upper>>>24] + 56; } }
java
public static int ntz(long val) { // A full binary search to determine the low byte was slower than // a linear search for nextSetBit(). This is most likely because // the implementation of nextSetBit() shifts bits to the right, increasing // the probability that the first non-zero byte is in the rhs. // // This implementation does a single binary search at the top level only // so that all other bit shifting can be done on ints instead of longs to // remain friendly to 32 bit architectures. In addition, the case of a // non-zero first byte is checked for first because it is the most common // in dense bit arrays. int lower = (int)val; int lowByte = lower & 0xff; if (lowByte != 0) return ntzTable[lowByte]; if (lower!=0) { lowByte = (lower>>>8) & 0xff; if (lowByte != 0) return ntzTable[lowByte] + 8; lowByte = (lower>>>16) & 0xff; if (lowByte != 0) return ntzTable[lowByte] + 16; // no need to mask off low byte for the last byte in the 32 bit word // no need to check for zero on the last byte either. return ntzTable[lower>>>24] + 24; } else { // grab upper 32 bits int upper=(int)(val>>32); lowByte = upper & 0xff; if (lowByte != 0) return ntzTable[lowByte] + 32; lowByte = (upper>>>8) & 0xff; if (lowByte != 0) return ntzTable[lowByte] + 40; lowByte = (upper>>>16) & 0xff; if (lowByte != 0) return ntzTable[lowByte] + 48; // no need to mask off low byte for the last byte in the 32 bit word // no need to check for zero on the last byte either. return ntzTable[upper>>>24] + 56; } }
[ "public", "static", "int", "ntz", "(", "long", "val", ")", "{", "// A full binary search to determine the low byte was slower than", "// a linear search for nextSetBit(). This is most likely because", "// the implementation of nextSetBit() shifts bits to the right, increasing", "// the prob...
Returns number of trailing zeros in a 64 bit long value.
[ "Returns", "number", "of", "trailing", "zeros", "in", "a", "64", "bit", "long", "value", "." ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/utils/obs/BitUtil.java#L691-L728
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/utils/obs/BitUtil.java
BitUtil.ntz
public static int ntz(int val) { // This implementation does a single binary search at the top level only. // In addition, the case of a non-zero first byte is checked for first // because it is the most common in dense bit arrays. int lowByte = val & 0xff; if (lowByte != 0) return ntzTable[lowByte]; lowByte = (val>>>8) & 0xff; if (lowByte != 0) return ntzTable[lowByte] + 8; lowByte = (val>>>16) & 0xff; if (lowByte != 0) return ntzTable[lowByte] + 16; // no need to mask off low byte for the last byte. // no need to check for zero on the last byte either. return ntzTable[val>>>24] + 24; }
java
public static int ntz(int val) { // This implementation does a single binary search at the top level only. // In addition, the case of a non-zero first byte is checked for first // because it is the most common in dense bit arrays. int lowByte = val & 0xff; if (lowByte != 0) return ntzTable[lowByte]; lowByte = (val>>>8) & 0xff; if (lowByte != 0) return ntzTable[lowByte] + 8; lowByte = (val>>>16) & 0xff; if (lowByte != 0) return ntzTable[lowByte] + 16; // no need to mask off low byte for the last byte. // no need to check for zero on the last byte either. return ntzTable[val>>>24] + 24; }
[ "public", "static", "int", "ntz", "(", "int", "val", ")", "{", "// This implementation does a single binary search at the top level only.", "// In addition, the case of a non-zero first byte is checked for first", "// because it is the most common in dense bit arrays.", "int", "lowByte", ...
Returns number of trailing zeros in a 32 bit int value.
[ "Returns", "number", "of", "trailing", "zeros", "in", "a", "32", "bit", "int", "value", "." ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/utils/obs/BitUtil.java#L731-L745
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/dht/AbstractBounds.java
AbstractBounds.intersects
public boolean intersects(Iterable<Range<T>> ranges) { for (Range<T> range2 : ranges) { if (range2.intersects(this)) return true; } return false; }
java
public boolean intersects(Iterable<Range<T>> ranges) { for (Range<T> range2 : ranges) { if (range2.intersects(this)) return true; } return false; }
[ "public", "boolean", "intersects", "(", "Iterable", "<", "Range", "<", "T", ">", ">", "ranges", ")", "{", "for", "(", "Range", "<", "T", ">", "range2", ":", "ranges", ")", "{", "if", "(", "range2", ".", "intersects", "(", "this", ")", ")", "return"...
return true if @param range intersects any of the given @param ranges
[ "return", "true", "if" ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/dht/AbstractBounds.java#L81-L89
train
Stratio/stratio-cassandra
tools/stress/src/org/apache/cassandra/stress/StressAction.java
StressAction.warmup
private void warmup(OpDistributionFactory operations) { // warmup - do 50k iterations; by default hotspot compiles methods after 10k invocations PrintStream warmupOutput = new PrintStream(new OutputStream() { @Override public void write(int b) throws IOException { } } ); int iterations = 50000 * settings.node.nodes.size(); int threads = 20; if (settings.rate.maxThreads > 0) threads = Math.min(threads, settings.rate.maxThreads); if (settings.rate.threadCount > 0) threads = Math.min(threads, settings.rate.threadCount); for (OpDistributionFactory single : operations.each()) { // we need to warm up all the nodes in the cluster ideally, but we may not be the only stress instance; // so warm up all the nodes we're speaking to only. output.println(String.format("Warming up %s with %d iterations...", single.desc(), iterations)); run(single, threads, iterations, 0, null, null, warmupOutput); } }
java
private void warmup(OpDistributionFactory operations) { // warmup - do 50k iterations; by default hotspot compiles methods after 10k invocations PrintStream warmupOutput = new PrintStream(new OutputStream() { @Override public void write(int b) throws IOException { } } ); int iterations = 50000 * settings.node.nodes.size(); int threads = 20; if (settings.rate.maxThreads > 0) threads = Math.min(threads, settings.rate.maxThreads); if (settings.rate.threadCount > 0) threads = Math.min(threads, settings.rate.threadCount); for (OpDistributionFactory single : operations.each()) { // we need to warm up all the nodes in the cluster ideally, but we may not be the only stress instance; // so warm up all the nodes we're speaking to only. output.println(String.format("Warming up %s with %d iterations...", single.desc(), iterations)); run(single, threads, iterations, 0, null, null, warmupOutput); } }
[ "private", "void", "warmup", "(", "OpDistributionFactory", "operations", ")", "{", "// warmup - do 50k iterations; by default hotspot compiles methods after 10k invocations", "PrintStream", "warmupOutput", "=", "new", "PrintStream", "(", "new", "OutputStream", "(", ")", "{", ...
type provided separately to support recursive call for mixed command with each command type it is performing
[ "type", "provided", "separately", "to", "support", "recursive", "call", "for", "mixed", "command", "with", "each", "command", "type", "it", "is", "performing" ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/tools/stress/src/org/apache/cassandra/stress/StressAction.java#L86-L105
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/auth/Auth.java
Auth.isSuperuser
public static boolean isSuperuser(String username) { UntypedResultSet result = selectUser(username); return !result.isEmpty() && result.one().getBoolean("super"); }
java
public static boolean isSuperuser(String username) { UntypedResultSet result = selectUser(username); return !result.isEmpty() && result.one().getBoolean("super"); }
[ "public", "static", "boolean", "isSuperuser", "(", "String", "username", ")", "{", "UntypedResultSet", "result", "=", "selectUser", "(", "username", ")", ";", "return", "!", "result", ".", "isEmpty", "(", ")", "&&", "result", ".", "one", "(", ")", ".", "...
Checks if the user is a known superuser. @param username Username to query. @return true is the user is a superuser, false if they aren't or don't exist at all.
[ "Checks", "if", "the", "user", "is", "a", "known", "superuser", "." ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/auth/Auth.java#L95-L99
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/auth/Auth.java
Auth.deleteUser
public static void deleteUser(String username) throws RequestExecutionException { QueryProcessor.process(String.format("DELETE FROM %s.%s WHERE name = '%s'", AUTH_KS, USERS_CF, escape(username)), consistencyForUser(username)); }
java
public static void deleteUser(String username) throws RequestExecutionException { QueryProcessor.process(String.format("DELETE FROM %s.%s WHERE name = '%s'", AUTH_KS, USERS_CF, escape(username)), consistencyForUser(username)); }
[ "public", "static", "void", "deleteUser", "(", "String", "username", ")", "throws", "RequestExecutionException", "{", "QueryProcessor", ".", "process", "(", "String", ".", "format", "(", "\"DELETE FROM %s.%s WHERE name = '%s'\"", ",", "AUTH_KS", ",", "USERS_CF", ",", ...
Deletes the user from AUTH_KS.USERS_CF. @param username Username to delete. @throws RequestExecutionException
[ "Deletes", "the", "user", "from", "AUTH_KS", ".", "USERS_CF", "." ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/auth/Auth.java#L124-L131
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/auth/Auth.java
Auth.setup
public static void setup() { if (DatabaseDescriptor.getAuthenticator() instanceof AllowAllAuthenticator) return; setupAuthKeyspace(); setupTable(USERS_CF, USERS_CF_SCHEMA); DatabaseDescriptor.getAuthenticator().setup(); DatabaseDescriptor.getAuthorizer().setup(); // register a custom MigrationListener for permissions cleanup after dropped keyspaces/cfs. MigrationManager.instance.register(new AuthMigrationListener()); // the delay is here to give the node some time to see its peers - to reduce // "Skipped default superuser setup: some nodes were not ready" log spam. // It's the only reason for the delay. ScheduledExecutors.nonPeriodicTasks.schedule(new Runnable() { public void run() { setupDefaultSuperuser(); } }, SUPERUSER_SETUP_DELAY, TimeUnit.MILLISECONDS); try { String query = String.format("SELECT * FROM %s.%s WHERE name = ?", AUTH_KS, USERS_CF); selectUserStatement = (SelectStatement) QueryProcessor.parseStatement(query).prepare().statement; } catch (RequestValidationException e) { throw new AssertionError(e); // not supposed to happen } }
java
public static void setup() { if (DatabaseDescriptor.getAuthenticator() instanceof AllowAllAuthenticator) return; setupAuthKeyspace(); setupTable(USERS_CF, USERS_CF_SCHEMA); DatabaseDescriptor.getAuthenticator().setup(); DatabaseDescriptor.getAuthorizer().setup(); // register a custom MigrationListener for permissions cleanup after dropped keyspaces/cfs. MigrationManager.instance.register(new AuthMigrationListener()); // the delay is here to give the node some time to see its peers - to reduce // "Skipped default superuser setup: some nodes were not ready" log spam. // It's the only reason for the delay. ScheduledExecutors.nonPeriodicTasks.schedule(new Runnable() { public void run() { setupDefaultSuperuser(); } }, SUPERUSER_SETUP_DELAY, TimeUnit.MILLISECONDS); try { String query = String.format("SELECT * FROM %s.%s WHERE name = ?", AUTH_KS, USERS_CF); selectUserStatement = (SelectStatement) QueryProcessor.parseStatement(query).prepare().statement; } catch (RequestValidationException e) { throw new AssertionError(e); // not supposed to happen } }
[ "public", "static", "void", "setup", "(", ")", "{", "if", "(", "DatabaseDescriptor", ".", "getAuthenticator", "(", ")", "instanceof", "AllowAllAuthenticator", ")", "return", ";", "setupAuthKeyspace", "(", ")", ";", "setupTable", "(", "USERS_CF", ",", "USERS_CF_S...
Sets up Authenticator and Authorizer.
[ "Sets", "up", "Authenticator", "and", "Authorizer", "." ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/auth/Auth.java#L136-L170
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/auth/Auth.java
Auth.consistencyForUser
private static ConsistencyLevel consistencyForUser(String username) { if (username.equals(DEFAULT_SUPERUSER_NAME)) return ConsistencyLevel.QUORUM; else return ConsistencyLevel.LOCAL_ONE; }
java
private static ConsistencyLevel consistencyForUser(String username) { if (username.equals(DEFAULT_SUPERUSER_NAME)) return ConsistencyLevel.QUORUM; else return ConsistencyLevel.LOCAL_ONE; }
[ "private", "static", "ConsistencyLevel", "consistencyForUser", "(", "String", "username", ")", "{", "if", "(", "username", ".", "equals", "(", "DEFAULT_SUPERUSER_NAME", ")", ")", "return", "ConsistencyLevel", ".", "QUORUM", ";", "else", "return", "ConsistencyLevel",...
Only use QUORUM cl for the default superuser.
[ "Only", "use", "QUORUM", "cl", "for", "the", "default", "superuser", "." ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/auth/Auth.java#L173-L179
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/auth/Auth.java
Auth.setupTable
public static void setupTable(String name, String cql) { if (Schema.instance.getCFMetaData(AUTH_KS, name) == null) { try { CFStatement parsed = (CFStatement)QueryProcessor.parseStatement(cql); parsed.prepareKeyspace(AUTH_KS); CreateTableStatement statement = (CreateTableStatement) parsed.prepare().statement; CFMetaData cfm = statement.getCFMetaData().copy(CFMetaData.generateLegacyCfId(AUTH_KS, name)); assert cfm.cfName.equals(name); MigrationManager.announceNewColumnFamily(cfm); } catch (Exception e) { throw new AssertionError(e); } } }
java
public static void setupTable(String name, String cql) { if (Schema.instance.getCFMetaData(AUTH_KS, name) == null) { try { CFStatement parsed = (CFStatement)QueryProcessor.parseStatement(cql); parsed.prepareKeyspace(AUTH_KS); CreateTableStatement statement = (CreateTableStatement) parsed.prepare().statement; CFMetaData cfm = statement.getCFMetaData().copy(CFMetaData.generateLegacyCfId(AUTH_KS, name)); assert cfm.cfName.equals(name); MigrationManager.announceNewColumnFamily(cfm); } catch (Exception e) { throw new AssertionError(e); } } }
[ "public", "static", "void", "setupTable", "(", "String", "name", ",", "String", "cql", ")", "{", "if", "(", "Schema", ".", "instance", ".", "getCFMetaData", "(", "AUTH_KS", ",", "name", ")", "==", "null", ")", "{", "try", "{", "CFStatement", "parsed", ...
Set up table from given CREATE TABLE statement under system_auth keyspace, if not already done so. @param name name of the table @param cql CREATE TABLE statement
[ "Set", "up", "table", "from", "given", "CREATE", "TABLE", "statement", "under", "system_auth", "keyspace", "if", "not", "already", "done", "so", "." ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/auth/Auth.java#L203-L221
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/dht/RangeStreamer.java
RangeStreamer.getAllRangesWithSourcesFor
private Multimap<Range<Token>, InetAddress> getAllRangesWithSourcesFor(String keyspaceName, Collection<Range<Token>> desiredRanges) { AbstractReplicationStrategy strat = Keyspace.open(keyspaceName).getReplicationStrategy(); Multimap<Range<Token>, InetAddress> rangeAddresses = strat.getRangeAddresses(metadata.cloneOnlyTokenMap()); Multimap<Range<Token>, InetAddress> rangeSources = ArrayListMultimap.create(); for (Range<Token> desiredRange : desiredRanges) { for (Range<Token> range : rangeAddresses.keySet()) { if (range.contains(desiredRange)) { List<InetAddress> preferred = DatabaseDescriptor.getEndpointSnitch().getSortedListByProximity(address, rangeAddresses.get(range)); rangeSources.putAll(desiredRange, preferred); break; } } if (!rangeSources.keySet().contains(desiredRange)) throw new IllegalStateException("No sources found for " + desiredRange); } return rangeSources; }
java
private Multimap<Range<Token>, InetAddress> getAllRangesWithSourcesFor(String keyspaceName, Collection<Range<Token>> desiredRanges) { AbstractReplicationStrategy strat = Keyspace.open(keyspaceName).getReplicationStrategy(); Multimap<Range<Token>, InetAddress> rangeAddresses = strat.getRangeAddresses(metadata.cloneOnlyTokenMap()); Multimap<Range<Token>, InetAddress> rangeSources = ArrayListMultimap.create(); for (Range<Token> desiredRange : desiredRanges) { for (Range<Token> range : rangeAddresses.keySet()) { if (range.contains(desiredRange)) { List<InetAddress> preferred = DatabaseDescriptor.getEndpointSnitch().getSortedListByProximity(address, rangeAddresses.get(range)); rangeSources.putAll(desiredRange, preferred); break; } } if (!rangeSources.keySet().contains(desiredRange)) throw new IllegalStateException("No sources found for " + desiredRange); } return rangeSources; }
[ "private", "Multimap", "<", "Range", "<", "Token", ">", ",", "InetAddress", ">", "getAllRangesWithSourcesFor", "(", "String", "keyspaceName", ",", "Collection", "<", "Range", "<", "Token", ">", ">", "desiredRanges", ")", "{", "AbstractReplicationStrategy", "strat"...
Get a map of all ranges and their respective sources that are candidates for streaming the given ranges to us. For each range, the list of sources is sorted by proximity relative to the given destAddress.
[ "Get", "a", "map", "of", "all", "ranges", "and", "their", "respective", "sources", "that", "are", "candidates", "for", "streaming", "the", "given", "ranges", "to", "us", ".", "For", "each", "range", "the", "list", "of", "sources", "is", "sorted", "by", "...
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/dht/RangeStreamer.java#L165-L188
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/dht/RangeStreamer.java
RangeStreamer.getAllRangesWithStrictSourcesFor
private Multimap<Range<Token>, InetAddress> getAllRangesWithStrictSourcesFor(String table, Collection<Range<Token>> desiredRanges) { assert tokens != null; AbstractReplicationStrategy strat = Keyspace.open(table).getReplicationStrategy(); //Active ranges TokenMetadata metadataClone = metadata.cloneOnlyTokenMap(); Multimap<Range<Token>,InetAddress> addressRanges = strat.getRangeAddresses(metadataClone); //Pending ranges metadataClone.updateNormalTokens(tokens, address); Multimap<Range<Token>,InetAddress> pendingRangeAddresses = strat.getRangeAddresses(metadataClone); //Collects the source that will have its range moved to the new node Multimap<Range<Token>, InetAddress> rangeSources = ArrayListMultimap.create(); for (Range<Token> desiredRange : desiredRanges) { for (Map.Entry<Range<Token>, Collection<InetAddress>> preEntry : addressRanges.asMap().entrySet()) { if (preEntry.getKey().contains(desiredRange)) { Set<InetAddress> oldEndpoints = Sets.newHashSet(preEntry.getValue()); Set<InetAddress> newEndpoints = Sets.newHashSet(pendingRangeAddresses.get(desiredRange)); //Due to CASSANDRA-5953 we can have a higher RF then we have endpoints. //So we need to be careful to only be strict when endpoints == RF if (oldEndpoints.size() == strat.getReplicationFactor()) { oldEndpoints.removeAll(newEndpoints); assert oldEndpoints.size() == 1 : "Expected 1 endpoint but found " + oldEndpoints.size(); } rangeSources.put(desiredRange, oldEndpoints.iterator().next()); } } //Validate Collection<InetAddress> addressList = rangeSources.get(desiredRange); if (addressList == null || addressList.isEmpty()) throw new IllegalStateException("No sources found for " + desiredRange); if (addressList.size() > 1) throw new IllegalStateException("Multiple endpoints found for " + desiredRange); InetAddress sourceIp = addressList.iterator().next(); EndpointState sourceState = Gossiper.instance.getEndpointStateForEndpoint(sourceIp); if (Gossiper.instance.isEnabled() && (sourceState == null || !sourceState.isAlive())) throw new RuntimeException("A node required to move the data consistently is down ("+sourceIp+"). If you wish to move the data from a potentially inconsistent replica, restart the node with -Dcassandra.consistent.rangemovement=false"); } return rangeSources; }
java
private Multimap<Range<Token>, InetAddress> getAllRangesWithStrictSourcesFor(String table, Collection<Range<Token>> desiredRanges) { assert tokens != null; AbstractReplicationStrategy strat = Keyspace.open(table).getReplicationStrategy(); //Active ranges TokenMetadata metadataClone = metadata.cloneOnlyTokenMap(); Multimap<Range<Token>,InetAddress> addressRanges = strat.getRangeAddresses(metadataClone); //Pending ranges metadataClone.updateNormalTokens(tokens, address); Multimap<Range<Token>,InetAddress> pendingRangeAddresses = strat.getRangeAddresses(metadataClone); //Collects the source that will have its range moved to the new node Multimap<Range<Token>, InetAddress> rangeSources = ArrayListMultimap.create(); for (Range<Token> desiredRange : desiredRanges) { for (Map.Entry<Range<Token>, Collection<InetAddress>> preEntry : addressRanges.asMap().entrySet()) { if (preEntry.getKey().contains(desiredRange)) { Set<InetAddress> oldEndpoints = Sets.newHashSet(preEntry.getValue()); Set<InetAddress> newEndpoints = Sets.newHashSet(pendingRangeAddresses.get(desiredRange)); //Due to CASSANDRA-5953 we can have a higher RF then we have endpoints. //So we need to be careful to only be strict when endpoints == RF if (oldEndpoints.size() == strat.getReplicationFactor()) { oldEndpoints.removeAll(newEndpoints); assert oldEndpoints.size() == 1 : "Expected 1 endpoint but found " + oldEndpoints.size(); } rangeSources.put(desiredRange, oldEndpoints.iterator().next()); } } //Validate Collection<InetAddress> addressList = rangeSources.get(desiredRange); if (addressList == null || addressList.isEmpty()) throw new IllegalStateException("No sources found for " + desiredRange); if (addressList.size() > 1) throw new IllegalStateException("Multiple endpoints found for " + desiredRange); InetAddress sourceIp = addressList.iterator().next(); EndpointState sourceState = Gossiper.instance.getEndpointStateForEndpoint(sourceIp); if (Gossiper.instance.isEnabled() && (sourceState == null || !sourceState.isAlive())) throw new RuntimeException("A node required to move the data consistently is down ("+sourceIp+"). If you wish to move the data from a potentially inconsistent replica, restart the node with -Dcassandra.consistent.rangemovement=false"); } return rangeSources; }
[ "private", "Multimap", "<", "Range", "<", "Token", ">", ",", "InetAddress", ">", "getAllRangesWithStrictSourcesFor", "(", "String", "table", ",", "Collection", "<", "Range", "<", "Token", ">", ">", "desiredRanges", ")", "{", "assert", "tokens", "!=", "null", ...
Get a map of all ranges and the source that will be cleaned up once this bootstrapped node is added for the given ranges. For each range, the list should only contain a single source. This allows us to consistently migrate data without violating consistency.
[ "Get", "a", "map", "of", "all", "ranges", "and", "the", "source", "that", "will", "be", "cleaned", "up", "once", "this", "bootstrapped", "node", "is", "added", "for", "the", "given", "ranges", ".", "For", "each", "range", "the", "list", "should", "only",...
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/dht/RangeStreamer.java#L195-L248
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/dht/RangeStreamer.java
RangeStreamer.toFetch
Multimap<String, Map.Entry<InetAddress, Collection<Range<Token>>>> toFetch() { return toFetch; }
java
Multimap<String, Map.Entry<InetAddress, Collection<Range<Token>>>> toFetch() { return toFetch; }
[ "Multimap", "<", "String", ",", "Map", ".", "Entry", "<", "InetAddress", ",", "Collection", "<", "Range", "<", "Token", ">", ">", ">", ">", "toFetch", "(", ")", "{", "return", "toFetch", ";", "}" ]
For testing purposes
[ "For", "testing", "purposes" ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/dht/RangeStreamer.java#L298-L301
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/cql/CreateColumnFamilyStatement.java
CreateColumnFamilyStatement.validate
private void validate(List<ByteBuffer> variables) throws InvalidRequestException { // Ensure that exactly one key has been specified. if (keyValidator.size() < 1) throw new InvalidRequestException("You must specify a PRIMARY KEY"); else if (keyValidator.size() > 1) throw new InvalidRequestException("You may only specify one PRIMARY KEY"); AbstractType<?> comparator; try { cfProps.validate(); comparator = cfProps.getComparator(); } catch (ConfigurationException e) { throw new InvalidRequestException(e.toString()); } catch (SyntaxException e) { throw new InvalidRequestException(e.toString()); } for (Map.Entry<Term, String> column : columns.entrySet()) { ByteBuffer name = column.getKey().getByteBuffer(comparator, variables); if (keyAlias != null && keyAlias.equals(name)) throw new InvalidRequestException("Invalid column name: " + column.getKey().getText() + ", because it equals to the key_alias."); } }
java
private void validate(List<ByteBuffer> variables) throws InvalidRequestException { // Ensure that exactly one key has been specified. if (keyValidator.size() < 1) throw new InvalidRequestException("You must specify a PRIMARY KEY"); else if (keyValidator.size() > 1) throw new InvalidRequestException("You may only specify one PRIMARY KEY"); AbstractType<?> comparator; try { cfProps.validate(); comparator = cfProps.getComparator(); } catch (ConfigurationException e) { throw new InvalidRequestException(e.toString()); } catch (SyntaxException e) { throw new InvalidRequestException(e.toString()); } for (Map.Entry<Term, String> column : columns.entrySet()) { ByteBuffer name = column.getKey().getByteBuffer(comparator, variables); if (keyAlias != null && keyAlias.equals(name)) throw new InvalidRequestException("Invalid column name: " + column.getKey().getText() + ", because it equals to the key_alias."); } }
[ "private", "void", "validate", "(", "List", "<", "ByteBuffer", ">", "variables", ")", "throws", "InvalidRequestException", "{", "// Ensure that exactly one key has been specified.", "if", "(", "keyValidator", ".", "size", "(", ")", "<", "1", ")", "throw", "new", "...
Perform validation of parsed params
[ "Perform", "validation", "of", "parsed", "params" ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/cql/CreateColumnFamilyStatement.java#L55-L89
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/db/commitlog/CommitLog.java
CommitLog.recover
public int recover() throws IOException { FilenameFilter unmanagedFilesFilter = new FilenameFilter() { public boolean accept(File dir, String name) { // we used to try to avoid instantiating commitlog (thus creating an empty segment ready for writes) // until after recover was finished. this turns out to be fragile; it is less error-prone to go // ahead and allow writes before recover(), and just skip active segments when we do. return CommitLogDescriptor.isValid(name) && !instance.allocator.manages(name); } }; // submit all existing files in the commit log dir for archiving prior to recovery - CASSANDRA-6904 for (File file : new File(DatabaseDescriptor.getCommitLogLocation()).listFiles(unmanagedFilesFilter)) { archiver.maybeArchive(file.getPath(), file.getName()); archiver.maybeWaitForArchiving(file.getName()); } assert archiver.archivePending.isEmpty() : "Not all commit log archive tasks were completed before restore"; archiver.maybeRestoreArchive(); File[] files = new File(DatabaseDescriptor.getCommitLogLocation()).listFiles(unmanagedFilesFilter); int replayed = 0; if (files.length == 0) { logger.info("No commitlog files found; skipping replay"); } else { Arrays.sort(files, new CommitLogSegmentFileComparator()); logger.info("Replaying {}", StringUtils.join(files, ", ")); replayed = recover(files); logger.info("Log replay complete, {} replayed mutations", replayed); for (File f : files) CommitLog.instance.allocator.recycleSegment(f); } allocator.enableReserveSegmentCreation(); return replayed; }
java
public int recover() throws IOException { FilenameFilter unmanagedFilesFilter = new FilenameFilter() { public boolean accept(File dir, String name) { // we used to try to avoid instantiating commitlog (thus creating an empty segment ready for writes) // until after recover was finished. this turns out to be fragile; it is less error-prone to go // ahead and allow writes before recover(), and just skip active segments when we do. return CommitLogDescriptor.isValid(name) && !instance.allocator.manages(name); } }; // submit all existing files in the commit log dir for archiving prior to recovery - CASSANDRA-6904 for (File file : new File(DatabaseDescriptor.getCommitLogLocation()).listFiles(unmanagedFilesFilter)) { archiver.maybeArchive(file.getPath(), file.getName()); archiver.maybeWaitForArchiving(file.getName()); } assert archiver.archivePending.isEmpty() : "Not all commit log archive tasks were completed before restore"; archiver.maybeRestoreArchive(); File[] files = new File(DatabaseDescriptor.getCommitLogLocation()).listFiles(unmanagedFilesFilter); int replayed = 0; if (files.length == 0) { logger.info("No commitlog files found; skipping replay"); } else { Arrays.sort(files, new CommitLogSegmentFileComparator()); logger.info("Replaying {}", StringUtils.join(files, ", ")); replayed = recover(files); logger.info("Log replay complete, {} replayed mutations", replayed); for (File f : files) CommitLog.instance.allocator.recycleSegment(f); } allocator.enableReserveSegmentCreation(); return replayed; }
[ "public", "int", "recover", "(", ")", "throws", "IOException", "{", "FilenameFilter", "unmanagedFilesFilter", "=", "new", "FilenameFilter", "(", ")", "{", "public", "boolean", "accept", "(", "File", "dir", ",", "String", "name", ")", "{", "// we used to try to a...
Perform recovery on commit logs located in the directory specified by the config file. @return the number of mutations replayed
[ "Perform", "recovery", "on", "commit", "logs", "located", "in", "the", "directory", "specified", "by", "the", "config", "file", "." ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/commitlog/CommitLog.java#L95-L137
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/db/commitlog/CommitLog.java
CommitLog.recover
public int recover(File... clogs) throws IOException { CommitLogReplayer recovery = new CommitLogReplayer(); recovery.recover(clogs); return recovery.blockForWrites(); }
java
public int recover(File... clogs) throws IOException { CommitLogReplayer recovery = new CommitLogReplayer(); recovery.recover(clogs); return recovery.blockForWrites(); }
[ "public", "int", "recover", "(", "File", "...", "clogs", ")", "throws", "IOException", "{", "CommitLogReplayer", "recovery", "=", "new", "CommitLogReplayer", "(", ")", ";", "recovery", ".", "recover", "(", "clogs", ")", ";", "return", "recovery", ".", "block...
Perform recovery on a list of commit log files. @param clogs the list of commit log files to replay @return the number of mutations replayed
[ "Perform", "recovery", "on", "a", "list", "of", "commit", "log", "files", "." ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/commitlog/CommitLog.java#L145-L150
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/db/commitlog/CommitLog.java
CommitLog.sync
public void sync(boolean syncAllSegments) { CommitLogSegment current = allocator.allocatingFrom(); for (CommitLogSegment segment : allocator.getActiveSegments()) { if (!syncAllSegments && segment.id > current.id) return; segment.sync(); } }
java
public void sync(boolean syncAllSegments) { CommitLogSegment current = allocator.allocatingFrom(); for (CommitLogSegment segment : allocator.getActiveSegments()) { if (!syncAllSegments && segment.id > current.id) return; segment.sync(); } }
[ "public", "void", "sync", "(", "boolean", "syncAllSegments", ")", "{", "CommitLogSegment", "current", "=", "allocator", ".", "allocatingFrom", "(", ")", ";", "for", "(", "CommitLogSegment", "segment", ":", "allocator", ".", "getActiveSegments", "(", ")", ")", ...
Forces a disk flush on the commit log files that need it. Blocking.
[ "Forces", "a", "disk", "flush", "on", "the", "commit", "log", "files", "that", "need", "it", ".", "Blocking", "." ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/commitlog/CommitLog.java#L188-L197
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/db/commitlog/CommitLog.java
CommitLog.add
public ReplayPosition add(Mutation mutation) { assert mutation != null; long size = Mutation.serializer.serializedSize(mutation, MessagingService.current_version); long totalSize = size + ENTRY_OVERHEAD_SIZE; if (totalSize > MAX_MUTATION_SIZE) { throw new IllegalArgumentException(String.format("Mutation of %s bytes is too large for the maxiumum size of %s", totalSize, MAX_MUTATION_SIZE)); } Allocation alloc = allocator.allocate(mutation, (int) totalSize); try { PureJavaCrc32 checksum = new PureJavaCrc32(); final ByteBuffer buffer = alloc.getBuffer(); DataOutputByteBuffer dos = new DataOutputByteBuffer(buffer); // checksummed length dos.writeInt((int) size); checksum.update(buffer, buffer.position() - 4, 4); buffer.putInt(checksum.getCrc()); int start = buffer.position(); // checksummed mutation Mutation.serializer.serialize(mutation, dos, MessagingService.current_version); checksum.update(buffer, start, (int) size); buffer.putInt(checksum.getCrc()); } catch (IOException e) { throw new FSWriteError(e, alloc.getSegment().getPath()); } finally { alloc.markWritten(); } executor.finishWriteFor(alloc); return alloc.getReplayPosition(); }
java
public ReplayPosition add(Mutation mutation) { assert mutation != null; long size = Mutation.serializer.serializedSize(mutation, MessagingService.current_version); long totalSize = size + ENTRY_OVERHEAD_SIZE; if (totalSize > MAX_MUTATION_SIZE) { throw new IllegalArgumentException(String.format("Mutation of %s bytes is too large for the maxiumum size of %s", totalSize, MAX_MUTATION_SIZE)); } Allocation alloc = allocator.allocate(mutation, (int) totalSize); try { PureJavaCrc32 checksum = new PureJavaCrc32(); final ByteBuffer buffer = alloc.getBuffer(); DataOutputByteBuffer dos = new DataOutputByteBuffer(buffer); // checksummed length dos.writeInt((int) size); checksum.update(buffer, buffer.position() - 4, 4); buffer.putInt(checksum.getCrc()); int start = buffer.position(); // checksummed mutation Mutation.serializer.serialize(mutation, dos, MessagingService.current_version); checksum.update(buffer, start, (int) size); buffer.putInt(checksum.getCrc()); } catch (IOException e) { throw new FSWriteError(e, alloc.getSegment().getPath()); } finally { alloc.markWritten(); } executor.finishWriteFor(alloc); return alloc.getReplayPosition(); }
[ "public", "ReplayPosition", "add", "(", "Mutation", "mutation", ")", "{", "assert", "mutation", "!=", "null", ";", "long", "size", "=", "Mutation", ".", "serializer", ".", "serializedSize", "(", "mutation", ",", "MessagingService", ".", "current_version", ")", ...
Add a Mutation to the commit log. @param mutation the Mutation to add to the log
[ "Add", "a", "Mutation", "to", "the", "commit", "log", "." ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/commitlog/CommitLog.java#L212-L254
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/db/commitlog/CommitLog.java
CommitLog.discardCompletedSegments
public void discardCompletedSegments(final UUID cfId, final ReplayPosition context) { logger.debug("discard completed log segments for {}, column family {}", context, cfId); // Go thru the active segment files, which are ordered oldest to newest, marking the // flushed CF as clean, until we reach the segment file containing the ReplayPosition passed // in the arguments. Any segments that become unused after they are marked clean will be // recycled or discarded. for (Iterator<CommitLogSegment> iter = allocator.getActiveSegments().iterator(); iter.hasNext();) { CommitLogSegment segment = iter.next(); segment.markClean(cfId, context); if (segment.isUnused()) { logger.debug("Commit log segment {} is unused", segment); allocator.recycleSegment(segment); } else { logger.debug("Not safe to delete{} commit log segment {}; dirty is {}", (iter.hasNext() ? "" : " active"), segment, segment.dirtyString()); } // Don't mark or try to delete any newer segments once we've reached the one containing the // position of the flush. if (segment.contains(context)) break; } }
java
public void discardCompletedSegments(final UUID cfId, final ReplayPosition context) { logger.debug("discard completed log segments for {}, column family {}", context, cfId); // Go thru the active segment files, which are ordered oldest to newest, marking the // flushed CF as clean, until we reach the segment file containing the ReplayPosition passed // in the arguments. Any segments that become unused after they are marked clean will be // recycled or discarded. for (Iterator<CommitLogSegment> iter = allocator.getActiveSegments().iterator(); iter.hasNext();) { CommitLogSegment segment = iter.next(); segment.markClean(cfId, context); if (segment.isUnused()) { logger.debug("Commit log segment {} is unused", segment); allocator.recycleSegment(segment); } else { logger.debug("Not safe to delete{} commit log segment {}; dirty is {}", (iter.hasNext() ? "" : " active"), segment, segment.dirtyString()); } // Don't mark or try to delete any newer segments once we've reached the one containing the // position of the flush. if (segment.contains(context)) break; } }
[ "public", "void", "discardCompletedSegments", "(", "final", "UUID", "cfId", ",", "final", "ReplayPosition", "context", ")", "{", "logger", ".", "debug", "(", "\"discard completed log segments for {}, column family {}\"", ",", "context", ",", "cfId", ")", ";", "// Go t...
Modifies the per-CF dirty cursors of any commit log segments for the column family according to the position given. Discards any commit log segments that are no longer used. @param cfId the column family ID that was flushed @param context the replay position of the flush
[ "Modifies", "the", "per", "-", "CF", "dirty", "cursors", "of", "any", "commit", "log", "segments", "for", "the", "column", "family", "according", "to", "the", "position", "given", ".", "Discards", "any", "commit", "log", "segments", "that", "are", "no", "l...
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/commitlog/CommitLog.java#L263-L292
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/db/commitlog/CommitLog.java
CommitLog.shutdownBlocking
public void shutdownBlocking() throws InterruptedException { executor.shutdown(); executor.awaitTermination(); allocator.shutdown(); allocator.awaitTermination(); }
java
public void shutdownBlocking() throws InterruptedException { executor.shutdown(); executor.awaitTermination(); allocator.shutdown(); allocator.awaitTermination(); }
[ "public", "void", "shutdownBlocking", "(", ")", "throws", "InterruptedException", "{", "executor", ".", "shutdown", "(", ")", ";", "executor", ".", "awaitTermination", "(", ")", ";", "allocator", ".", "shutdown", "(", ")", ";", "allocator", ".", "awaitTerminat...
Shuts down the threads used by the commit log, blocking until completion.
[ "Shuts", "down", "the", "threads", "used", "by", "the", "commit", "log", "blocking", "until", "completion", "." ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/commitlog/CommitLog.java#L360-L366
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/dht/Bounds.java
Bounds.makeRowBounds
public static Bounds<RowPosition> makeRowBounds(Token left, Token right, IPartitioner partitioner) { return new Bounds<RowPosition>(left.minKeyBound(partitioner), right.maxKeyBound(partitioner), partitioner); }
java
public static Bounds<RowPosition> makeRowBounds(Token left, Token right, IPartitioner partitioner) { return new Bounds<RowPosition>(left.minKeyBound(partitioner), right.maxKeyBound(partitioner), partitioner); }
[ "public", "static", "Bounds", "<", "RowPosition", ">", "makeRowBounds", "(", "Token", "left", ",", "Token", "right", ",", "IPartitioner", "partitioner", ")", "{", "return", "new", "Bounds", "<", "RowPosition", ">", "(", "left", ".", "minKeyBound", "(", "part...
Compute a bounds of keys corresponding to a given bounds of token.
[ "Compute", "a", "bounds", "of", "keys", "corresponding", "to", "a", "given", "bounds", "of", "token", "." ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/dht/Bounds.java#L114-L117
train
Stratio/stratio-cassandra
tools/stress/src/org/apache/cassandra/stress/util/SampleOfLongs.java
SampleOfLongs.rankLatency
public double rankLatency(float rank) { if (sample.length == 0) return 0; int index = (int)(rank * sample.length); if (index >= sample.length) index = sample.length - 1; return sample[index] * 0.000001d; }
java
public double rankLatency(float rank) { if (sample.length == 0) return 0; int index = (int)(rank * sample.length); if (index >= sample.length) index = sample.length - 1; return sample[index] * 0.000001d; }
[ "public", "double", "rankLatency", "(", "float", "rank", ")", "{", "if", "(", "sample", ".", "length", "==", "0", ")", "return", "0", ";", "int", "index", "=", "(", "int", ")", "(", "rank", "*", "sample", ".", "length", ")", ";", "if", "(", "inde...
0 < rank < 1
[ "0", "<", "rank", "<", "1" ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/tools/stress/src/org/apache/cassandra/stress/util/SampleOfLongs.java#L100-L108
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
DynamicEndpointSnitch.maxScore
private double maxScore(List<InetAddress> endpoints) { double maxScore = -1.0; for (InetAddress endpoint : endpoints) { Double score = scores.get(endpoint); if (score == null) continue; if (score > maxScore) maxScore = score; } return maxScore; }
java
private double maxScore(List<InetAddress> endpoints) { double maxScore = -1.0; for (InetAddress endpoint : endpoints) { Double score = scores.get(endpoint); if (score == null) continue; if (score > maxScore) maxScore = score; } return maxScore; }
[ "private", "double", "maxScore", "(", "List", "<", "InetAddress", ">", "endpoints", ")", "{", "double", "maxScore", "=", "-", "1.0", ";", "for", "(", "InetAddress", "endpoint", ":", "endpoints", ")", "{", "Double", "score", "=", "scores", ".", "get", "("...
Return the max score for the endpoint in the provided list, or -1.0 if no node have a score.
[ "Return", "the", "max", "score", "for", "the", "endpoint", "in", "the", "provided", "list", "or", "-", "1", ".", "0", "if", "no", "node", "have", "a", "score", "." ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java#L339-L352
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/io/FSError.java
FSError.findNested
public static FSError findNested(Throwable top) { for (Throwable t = top; t != null; t = t.getCause()) { if (t instanceof FSError) return (FSError) t; } return null; }
java
public static FSError findNested(Throwable top) { for (Throwable t = top; t != null; t = t.getCause()) { if (t instanceof FSError) return (FSError) t; } return null; }
[ "public", "static", "FSError", "findNested", "(", "Throwable", "top", ")", "{", "for", "(", "Throwable", "t", "=", "top", ";", "t", "!=", "null", ";", "t", "=", "t", ".", "getCause", "(", ")", ")", "{", "if", "(", "t", "instanceof", "FSError", ")",...
Unwraps the Throwable cause chain looking for an FSError instance @param top the top-level Throwable to unwrap @return FSError if found any, null otherwise
[ "Unwraps", "the", "Throwable", "cause", "chain", "looking", "for", "an", "FSError", "instance" ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/io/FSError.java#L38-L47
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java
SizeTieredCompactionStrategy.hotness
private static double hotness(SSTableReader sstr) { // system tables don't have read meters, just use 0.0 for the hotness return sstr.getReadMeter() == null ? 0.0 : sstr.getReadMeter().twoHourRate() / sstr.estimatedKeys(); }
java
private static double hotness(SSTableReader sstr) { // system tables don't have read meters, just use 0.0 for the hotness return sstr.getReadMeter() == null ? 0.0 : sstr.getReadMeter().twoHourRate() / sstr.estimatedKeys(); }
[ "private", "static", "double", "hotness", "(", "SSTableReader", "sstr", ")", "{", "// system tables don't have read meters, just use 0.0 for the hotness", "return", "sstr", ".", "getReadMeter", "(", ")", "==", "null", "?", "0.0", ":", "sstr", ".", "getReadMeter", "(",...
Returns the reads per second per key for this sstable, or 0.0 if the sstable has no read meter
[ "Returns", "the", "reads", "per", "second", "per", "key", "for", "this", "sstable", "or", "0", ".", "0", "if", "the", "sstable", "has", "no", "read", "meter" ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/compaction/SizeTieredCompactionStrategy.java#L172-L176
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/cli/CliUtils.java
CliUtils.unescapeSQLString
public static String unescapeSQLString(String b) { if (b.charAt(0) == '\'' && b.charAt(b.length()-1) == '\'') b = b.substring(1, b.length()-1); return StringEscapeUtils.unescapeJava(b); }
java
public static String unescapeSQLString(String b) { if (b.charAt(0) == '\'' && b.charAt(b.length()-1) == '\'') b = b.substring(1, b.length()-1); return StringEscapeUtils.unescapeJava(b); }
[ "public", "static", "String", "unescapeSQLString", "(", "String", "b", ")", "{", "if", "(", "b", ".", "charAt", "(", "0", ")", "==", "'", "'", "&&", "b", ".", "charAt", "(", "b", ".", "length", "(", ")", "-", "1", ")", "==", "'", "'", ")", "b...
Strips leading and trailing "'" characters, and handles and escaped characters such as \n, \r, etc. @param b - string to unescape @return String - unexspaced string
[ "Strips", "leading", "and", "trailing", "characters", "and", "handles", "and", "escaped", "characters", "such", "as", "\\", "n", "\\", "r", "etc", "." ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/cli/CliUtils.java#L37-L42
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/cli/CliUtils.java
CliUtils.getIndexOperator
public static IndexOperator getIndexOperator(String operator) { if (operator.equals("=")) { return IndexOperator.EQ; } else if (operator.equals(">=")) { return IndexOperator.GTE; } else if (operator.equals(">")) { return IndexOperator.GT; } else if (operator.equals("<")) { return IndexOperator.LT; } else if (operator.equals("<=")) { return IndexOperator.LTE; } return null; }
java
public static IndexOperator getIndexOperator(String operator) { if (operator.equals("=")) { return IndexOperator.EQ; } else if (operator.equals(">=")) { return IndexOperator.GTE; } else if (operator.equals(">")) { return IndexOperator.GT; } else if (operator.equals("<")) { return IndexOperator.LT; } else if (operator.equals("<=")) { return IndexOperator.LTE; } return null; }
[ "public", "static", "IndexOperator", "getIndexOperator", "(", "String", "operator", ")", "{", "if", "(", "operator", ".", "equals", "(", "\"=\"", ")", ")", "{", "return", "IndexOperator", ".", "EQ", ";", "}", "else", "if", "(", "operator", ".", "equals", ...
Returns IndexOperator from string representation @param operator - string representing IndexOperator (=, >=, >, <, <=) @return IndexOperator - enum value of IndexOperator or null if not found
[ "Returns", "IndexOperator", "from", "string", "representation" ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/cli/CliUtils.java#L60-L84
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/cli/CliUtils.java
CliUtils.getCfNamesByKeySpace
public static Set<String> getCfNamesByKeySpace(KsDef keySpace) { Set<String> names = new LinkedHashSet<String>(); for (CfDef cfDef : keySpace.getCf_defs()) { names.add(cfDef.getName()); } return names; }
java
public static Set<String> getCfNamesByKeySpace(KsDef keySpace) { Set<String> names = new LinkedHashSet<String>(); for (CfDef cfDef : keySpace.getCf_defs()) { names.add(cfDef.getName()); } return names; }
[ "public", "static", "Set", "<", "String", ">", "getCfNamesByKeySpace", "(", "KsDef", "keySpace", ")", "{", "Set", "<", "String", ">", "names", "=", "new", "LinkedHashSet", "<", "String", ">", "(", ")", ";", "for", "(", "CfDef", "cfDef", ":", "keySpace", ...
Returns set of column family names in specified keySpace. @param keySpace - keyspace definition to get column family names from. @return Set - column family names
[ "Returns", "set", "of", "column", "family", "names", "in", "specified", "keySpace", "." ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/cli/CliUtils.java#L91-L101
train
Stratio/stratio-cassandra
src/java/org/apache/cassandra/cli/CliUtils.java
CliUtils.getKeySpaceDef
public static KsDef getKeySpaceDef(String keyspaceName, List<KsDef> keyspaces) { keyspaceName = keyspaceName.toUpperCase(); for (KsDef ksDef : keyspaces) { if (ksDef.name.toUpperCase().equals(keyspaceName)) return ksDef; } return null; }
java
public static KsDef getKeySpaceDef(String keyspaceName, List<KsDef> keyspaces) { keyspaceName = keyspaceName.toUpperCase(); for (KsDef ksDef : keyspaces) { if (ksDef.name.toUpperCase().equals(keyspaceName)) return ksDef; } return null; }
[ "public", "static", "KsDef", "getKeySpaceDef", "(", "String", "keyspaceName", ",", "List", "<", "KsDef", ">", "keyspaces", ")", "{", "keyspaceName", "=", "keyspaceName", ".", "toUpperCase", "(", ")", ";", "for", "(", "KsDef", "ksDef", ":", "keyspaces", ")", ...
Parse the statement from cli and return KsDef @param keyspaceName - name of the keyspace to lookup @param keyspaces - List of known keyspaces @return metadata about keyspace or null
[ "Parse", "the", "statement", "from", "cli", "and", "return", "KsDef" ]
f6416b43ad5309083349ad56266450fa8c6a2106
https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/cli/CliUtils.java#L111-L122
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.getViewHlr
public Hlr getViewHlr(final String hlrId) throws GeneralException, UnauthorizedException, NotFoundException { if (hlrId == null) { throw new IllegalArgumentException("Hrl ID must be specified."); } return messageBirdService.requestByID(HLRPATH, hlrId, Hlr.class); }
java
public Hlr getViewHlr(final String hlrId) throws GeneralException, UnauthorizedException, NotFoundException { if (hlrId == null) { throw new IllegalArgumentException("Hrl ID must be specified."); } return messageBirdService.requestByID(HLRPATH, hlrId, Hlr.class); }
[ "public", "Hlr", "getViewHlr", "(", "final", "String", "hlrId", ")", "throws", "GeneralException", ",", "UnauthorizedException", ",", "NotFoundException", "{", "if", "(", "hlrId", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Hrl ID m...
Retrieves the information of an existing HLR. You only need to supply the unique message id that was returned upon creation or receiving. @param hlrId ID as returned by getRequestHlr in the id variable @return Hlr Object @throws UnauthorizedException if client is unauthorized @throws GeneralException general exception
[ "Retrieves", "the", "information", "of", "an", "existing", "HLR", ".", "You", "only", "need", "to", "supply", "the", "unique", "message", "id", "that", "was", "returned", "upon", "creation", "or", "receiving", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L121-L126
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.sendMessage
public MessageResponse sendMessage(final Message message) throws UnauthorizedException, GeneralException { return messageBirdService.sendPayLoad(MESSAGESPATH, message, MessageResponse.class); }
java
public MessageResponse sendMessage(final Message message) throws UnauthorizedException, GeneralException { return messageBirdService.sendPayLoad(MESSAGESPATH, message, MessageResponse.class); }
[ "public", "MessageResponse", "sendMessage", "(", "final", "Message", "message", ")", "throws", "UnauthorizedException", ",", "GeneralException", "{", "return", "messageBirdService", ".", "sendPayLoad", "(", "MESSAGESPATH", ",", "message", ",", "MessageResponse", ".", ...
Send a message through the messagebird platform @param message Message object to be send @return Message Response @throws UnauthorizedException if client is unauthorized @throws GeneralException general exception
[ "Send", "a", "message", "through", "the", "messagebird", "platform" ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L140-L142
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.sendFlashMessage
public MessageResponse sendFlashMessage(final String originator, final String body, final List<BigInteger> recipients) throws UnauthorizedException, GeneralException { final Message message = new Message(originator, body, recipients); message.setType(MsgType.flash); return messageBirdService.sendPayLoad(MESSAGESPATH, message, MessageResponse.class); }
java
public MessageResponse sendFlashMessage(final String originator, final String body, final List<BigInteger> recipients) throws UnauthorizedException, GeneralException { final Message message = new Message(originator, body, recipients); message.setType(MsgType.flash); return messageBirdService.sendPayLoad(MESSAGESPATH, message, MessageResponse.class); }
[ "public", "MessageResponse", "sendFlashMessage", "(", "final", "String", "originator", ",", "final", "String", "body", ",", "final", "List", "<", "BigInteger", ">", "recipients", ")", "throws", "UnauthorizedException", ",", "GeneralException", "{", "final", "Message...
Convenient function to send a simple flash message to a list of recipients @param originator Originator of the message, this will get truncated to 11 chars @param body Body of the message @param recipients List of recipients @return MessageResponse @throws UnauthorizedException if client is unauthorized @throws GeneralException general exception
[ "Convenient", "function", "to", "send", "a", "simple", "flash", "message", "to", "a", "list", "of", "recipients" ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L185-L189
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.deleteMessage
public void deleteMessage(final String id) throws UnauthorizedException, GeneralException, NotFoundException { if (id == null) { throw new IllegalArgumentException("Message ID must be specified."); } messageBirdService.deleteByID(MESSAGESPATH, id); }
java
public void deleteMessage(final String id) throws UnauthorizedException, GeneralException, NotFoundException { if (id == null) { throw new IllegalArgumentException("Message ID must be specified."); } messageBirdService.deleteByID(MESSAGESPATH, id); }
[ "public", "void", "deleteMessage", "(", "final", "String", "id", ")", "throws", "UnauthorizedException", ",", "GeneralException", ",", "NotFoundException", "{", "if", "(", "id", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Message ID...
Delete a message from the Messagebird server @param id A unique random ID which is created on the MessageBird platform @throws UnauthorizedException if client is unauthorized @throws GeneralException general exception
[ "Delete", "a", "message", "from", "the", "Messagebird", "server" ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L226-L231
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.deleteVoiceMessage
public void deleteVoiceMessage(final String id) throws UnauthorizedException, GeneralException, NotFoundException { if (id == null) { throw new IllegalArgumentException("Message ID must be specified."); } messageBirdService.deleteByID(VOICEMESSAGESPATH, id); }
java
public void deleteVoiceMessage(final String id) throws UnauthorizedException, GeneralException, NotFoundException { if (id == null) { throw new IllegalArgumentException("Message ID must be specified."); } messageBirdService.deleteByID(VOICEMESSAGESPATH, id); }
[ "public", "void", "deleteVoiceMessage", "(", "final", "String", "id", ")", "throws", "UnauthorizedException", ",", "GeneralException", ",", "NotFoundException", "{", "if", "(", "id", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Messa...
Delete a voice message from the Messagebird server @param id A unique random ID which is created on the MessageBird platform @throws UnauthorizedException if client is unauthorized @throws GeneralException general exception
[ "Delete", "a", "voice", "message", "from", "the", "Messagebird", "server" ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L301-L306
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.listVoiceMessages
public VoiceMessageList listVoiceMessages(final Integer offset, final Integer limit) throws UnauthorizedException, GeneralException { if (offset != null && offset < 0) { throw new IllegalArgumentException("Offset must be > 0"); } if (limit != null && limit < 0) { throw new IllegalArgumentException("Limit must be > 0"); } return messageBirdService.requestList(VOICEMESSAGESPATH, offset, limit, VoiceMessageList.class); }
java
public VoiceMessageList listVoiceMessages(final Integer offset, final Integer limit) throws UnauthorizedException, GeneralException { if (offset != null && offset < 0) { throw new IllegalArgumentException("Offset must be > 0"); } if (limit != null && limit < 0) { throw new IllegalArgumentException("Limit must be > 0"); } return messageBirdService.requestList(VOICEMESSAGESPATH, offset, limit, VoiceMessageList.class); }
[ "public", "VoiceMessageList", "listVoiceMessages", "(", "final", "Integer", "offset", ",", "final", "Integer", "limit", ")", "throws", "UnauthorizedException", ",", "GeneralException", "{", "if", "(", "offset", "!=", "null", "&&", "offset", "<", "0", ")", "{", ...
List voice messages @param offset offset for result list @param limit limit for result list @return VoiceMessageList @throws UnauthorizedException if client is unauthorized @throws GeneralException general exception
[ "List", "voice", "messages" ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L332-L340
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.deleteContact
void deleteContact(final String id) throws NotFoundException, GeneralException, UnauthorizedException { if (id == null) { throw new IllegalArgumentException("Contact ID must be specified."); } messageBirdService.deleteByID(CONTACTPATH, id); }
java
void deleteContact(final String id) throws NotFoundException, GeneralException, UnauthorizedException { if (id == null) { throw new IllegalArgumentException("Contact ID must be specified."); } messageBirdService.deleteByID(CONTACTPATH, id); }
[ "void", "deleteContact", "(", "final", "String", "id", ")", "throws", "NotFoundException", ",", "GeneralException", ",", "UnauthorizedException", "{", "if", "(", "id", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Contact ID must be spe...
Deletes an existing contact. You only need to supply the unique id that was returned upon creation.
[ "Deletes", "an", "existing", "contact", ".", "You", "only", "need", "to", "supply", "the", "unique", "id", "that", "was", "returned", "upon", "creation", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L541-L546
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.sendContact
public Contact sendContact(final ContactRequest contactRequest) throws UnauthorizedException, GeneralException { return messageBirdService.sendPayLoad(CONTACTPATH, contactRequest, Contact.class); }
java
public Contact sendContact(final ContactRequest contactRequest) throws UnauthorizedException, GeneralException { return messageBirdService.sendPayLoad(CONTACTPATH, contactRequest, Contact.class); }
[ "public", "Contact", "sendContact", "(", "final", "ContactRequest", "contactRequest", ")", "throws", "UnauthorizedException", ",", "GeneralException", "{", "return", "messageBirdService", ".", "sendPayLoad", "(", "CONTACTPATH", ",", "contactRequest", ",", "Contact", "."...
Creates a new contact object. MessageBird returns the created contact object with each request.
[ "Creates", "a", "new", "contact", "object", ".", "MessageBird", "returns", "the", "created", "contact", "object", "with", "each", "request", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L571-L573
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.updateContact
public Contact updateContact(final String id, ContactRequest contactRequest) throws UnauthorizedException, GeneralException { if (id == null) { throw new IllegalArgumentException("Contact ID must be specified."); } String request = CONTACTPATH + "/" + id; return messageBirdService.sendPayLoad("PATCH", request, contactRequest, Contact.class); }
java
public Contact updateContact(final String id, ContactRequest contactRequest) throws UnauthorizedException, GeneralException { if (id == null) { throw new IllegalArgumentException("Contact ID must be specified."); } String request = CONTACTPATH + "/" + id; return messageBirdService.sendPayLoad("PATCH", request, contactRequest, Contact.class); }
[ "public", "Contact", "updateContact", "(", "final", "String", "id", ",", "ContactRequest", "contactRequest", ")", "throws", "UnauthorizedException", ",", "GeneralException", "{", "if", "(", "id", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", ...
Updates an existing contact. You only need to supply the unique id that was returned upon creation.
[ "Updates", "an", "existing", "contact", ".", "You", "only", "need", "to", "supply", "the", "unique", "id", "that", "was", "returned", "upon", "creation", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L579-L585
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.viewContact
public Contact viewContact(final String id) throws NotFoundException, GeneralException, UnauthorizedException { if (id == null) { throw new IllegalArgumentException("Contact ID must be specified."); } return messageBirdService.requestByID(CONTACTPATH, id, Contact.class); }
java
public Contact viewContact(final String id) throws NotFoundException, GeneralException, UnauthorizedException { if (id == null) { throw new IllegalArgumentException("Contact ID must be specified."); } return messageBirdService.requestByID(CONTACTPATH, id, Contact.class); }
[ "public", "Contact", "viewContact", "(", "final", "String", "id", ")", "throws", "NotFoundException", ",", "GeneralException", ",", "UnauthorizedException", "{", "if", "(", "id", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Contact I...
Retrieves the information of an existing contact. You only need to supply the unique contact ID that was returned upon creation or receiving.
[ "Retrieves", "the", "information", "of", "an", "existing", "contact", ".", "You", "only", "need", "to", "supply", "the", "unique", "contact", "ID", "that", "was", "returned", "upon", "creation", "or", "receiving", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L591-L596
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.deleteGroup
public void deleteGroup(final String id) throws NotFoundException, GeneralException, UnauthorizedException { if (id == null) { throw new IllegalArgumentException("Group ID must be specified."); } messageBirdService.deleteByID(GROUPPATH, id); }
java
public void deleteGroup(final String id) throws NotFoundException, GeneralException, UnauthorizedException { if (id == null) { throw new IllegalArgumentException("Group ID must be specified."); } messageBirdService.deleteByID(GROUPPATH, id); }
[ "public", "void", "deleteGroup", "(", "final", "String", "id", ")", "throws", "NotFoundException", ",", "GeneralException", ",", "UnauthorizedException", "{", "if", "(", "id", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Group ID mus...
Deletes an existing group. You only need to supply the unique id that was returned upon creation.
[ "Deletes", "an", "existing", "group", ".", "You", "only", "need", "to", "supply", "the", "unique", "id", "that", "was", "returned", "upon", "creation", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L602-L607
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.deleteGroupContact
public void deleteGroupContact(final String groupId, final String contactId) throws NotFoundException, GeneralException, UnauthorizedException { if (groupId == null) { throw new IllegalArgumentException("Group ID must be specified."); } if (contactId == null) { throw new IllegalArgumentException("Contact ID must be specified."); } String id = String.format("%s%s/%s", groupId, CONTACTPATH, contactId); messageBirdService.deleteByID(GROUPPATH, id); }
java
public void deleteGroupContact(final String groupId, final String contactId) throws NotFoundException, GeneralException, UnauthorizedException { if (groupId == null) { throw new IllegalArgumentException("Group ID must be specified."); } if (contactId == null) { throw new IllegalArgumentException("Contact ID must be specified."); } String id = String.format("%s%s/%s", groupId, CONTACTPATH, contactId); messageBirdService.deleteByID(GROUPPATH, id); }
[ "public", "void", "deleteGroupContact", "(", "final", "String", "groupId", ",", "final", "String", "contactId", ")", "throws", "NotFoundException", ",", "GeneralException", ",", "UnauthorizedException", "{", "if", "(", "groupId", "==", "null", ")", "{", "throw", ...
Removes a contact from group. You need to supply the IDs of the group and contact. Does not delete the contact.
[ "Removes", "a", "contact", "from", "group", ".", "You", "need", "to", "supply", "the", "IDs", "of", "the", "group", "and", "contact", ".", "Does", "not", "delete", "the", "contact", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L613-L623
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.sendGroup
public Group sendGroup(final GroupRequest groupRequest) throws UnauthorizedException, GeneralException { return messageBirdService.sendPayLoad(GROUPPATH, groupRequest, Group.class); }
java
public Group sendGroup(final GroupRequest groupRequest) throws UnauthorizedException, GeneralException { return messageBirdService.sendPayLoad(GROUPPATH, groupRequest, Group.class); }
[ "public", "Group", "sendGroup", "(", "final", "GroupRequest", "groupRequest", ")", "throws", "UnauthorizedException", ",", "GeneralException", "{", "return", "messageBirdService", ".", "sendPayLoad", "(", "GROUPPATH", ",", "groupRequest", ",", "Group", ".", "class", ...
Creates a new group object. MessageBird returns the created group object with each request.
[ "Creates", "a", "new", "group", "object", ".", "MessageBird", "returns", "the", "created", "group", "object", "with", "each", "request", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L646-L648
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.sendGroupContact
public void sendGroupContact(final String groupId, final String[] contactIds) throws NotFoundException, GeneralException, UnauthorizedException { // reuestByID appends the "ID" to the base path, so this workaround // lets us add a query string. String path = String.format("%s%s?%s", groupId, CONTACTPATH, getQueryString(contactIds)); messageBirdService.requestByID(GROUPPATH, path, null); }
java
public void sendGroupContact(final String groupId, final String[] contactIds) throws NotFoundException, GeneralException, UnauthorizedException { // reuestByID appends the "ID" to the base path, so this workaround // lets us add a query string. String path = String.format("%s%s?%s", groupId, CONTACTPATH, getQueryString(contactIds)); messageBirdService.requestByID(GROUPPATH, path, null); }
[ "public", "void", "sendGroupContact", "(", "final", "String", "groupId", ",", "final", "String", "[", "]", "contactIds", ")", "throws", "NotFoundException", ",", "GeneralException", ",", "UnauthorizedException", "{", "// reuestByID appends the \"ID\" to the base path, so th...
Adds contact to group. You need to supply the IDs of the group and contact.
[ "Adds", "contact", "to", "group", ".", "You", "need", "to", "supply", "the", "IDs", "of", "the", "group", "and", "contact", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L654-L659
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.updateGroup
public Group updateGroup(final String id, final GroupRequest groupRequest) throws UnauthorizedException, GeneralException { if (id == null) { throw new IllegalArgumentException("Group ID must be specified."); } String path = String.format("%s/%s", GROUPPATH, id); return messageBirdService.sendPayLoad("PATCH", path, groupRequest, Group.class); }
java
public Group updateGroup(final String id, final GroupRequest groupRequest) throws UnauthorizedException, GeneralException { if (id == null) { throw new IllegalArgumentException("Group ID must be specified."); } String path = String.format("%s/%s", GROUPPATH, id); return messageBirdService.sendPayLoad("PATCH", path, groupRequest, Group.class); }
[ "public", "Group", "updateGroup", "(", "final", "String", "id", ",", "final", "GroupRequest", "groupRequest", ")", "throws", "UnauthorizedException", ",", "GeneralException", "{", "if", "(", "id", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException",...
Updates an existing group. You only need to supply the unique ID that was returned upon creation.
[ "Updates", "an", "existing", "group", ".", "You", "only", "need", "to", "supply", "the", "unique", "ID", "that", "was", "returned", "upon", "creation", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L684-L690
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.viewGroup
public Group viewGroup(final String id) throws NotFoundException, GeneralException, UnauthorizedException { if (id == null) { throw new IllegalArgumentException("Group ID must be specified."); } return messageBirdService.requestByID(GROUPPATH, id, Group.class); }
java
public Group viewGroup(final String id) throws NotFoundException, GeneralException, UnauthorizedException { if (id == null) { throw new IllegalArgumentException("Group ID must be specified."); } return messageBirdService.requestByID(GROUPPATH, id, Group.class); }
[ "public", "Group", "viewGroup", "(", "final", "String", "id", ")", "throws", "NotFoundException", ",", "GeneralException", ",", "UnauthorizedException", "{", "if", "(", "id", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Group ID must...
Retrieves the information of an existing group. You only need to supply the unique group ID that was returned upon creation or receiving.
[ "Retrieves", "the", "information", "of", "an", "existing", "group", ".", "You", "only", "need", "to", "supply", "the", "unique", "group", "ID", "that", "was", "returned", "upon", "creation", "or", "receiving", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L696-L701
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.viewConversation
public Conversation viewConversation(final String id) throws NotFoundException, GeneralException, UnauthorizedException { if (id == null) { throw new IllegalArgumentException("Id must be specified"); } String url = CONVERSATIONS_BASE_URL + CONVERSATION_PATH; return messageBirdService.requestByID(url, id, Conversation.class); }
java
public Conversation viewConversation(final String id) throws NotFoundException, GeneralException, UnauthorizedException { if (id == null) { throw new IllegalArgumentException("Id must be specified"); } String url = CONVERSATIONS_BASE_URL + CONVERSATION_PATH; return messageBirdService.requestByID(url, id, Conversation.class); }
[ "public", "Conversation", "viewConversation", "(", "final", "String", "id", ")", "throws", "NotFoundException", ",", "GeneralException", ",", "UnauthorizedException", "{", "if", "(", "id", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\...
Gets a single conversation. @param id Conversation to retrieved. @return The retrieved conversation.
[ "Gets", "a", "single", "conversation", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L709-L715
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.updateConversation
public Conversation updateConversation(final String id, final ConversationStatus status) throws UnauthorizedException, GeneralException { if (id == null) { throw new IllegalArgumentException("Id must be specified."); } String url = String.format("%s%s/%s", CONVERSATIONS_BASE_URL, CONVERSATION_PATH, id); return messageBirdService.sendPayLoad("PATCH", url, status, Conversation.class); }
java
public Conversation updateConversation(final String id, final ConversationStatus status) throws UnauthorizedException, GeneralException { if (id == null) { throw new IllegalArgumentException("Id must be specified."); } String url = String.format("%s%s/%s", CONVERSATIONS_BASE_URL, CONVERSATION_PATH, id); return messageBirdService.sendPayLoad("PATCH", url, status, Conversation.class); }
[ "public", "Conversation", "updateConversation", "(", "final", "String", "id", ",", "final", "ConversationStatus", "status", ")", "throws", "UnauthorizedException", ",", "GeneralException", "{", "if", "(", "id", "==", "null", ")", "{", "throw", "new", "IllegalArgum...
Updates a conversation. @param id Conversation to update. @param status New status for the conversation. @return The updated Conversation.
[ "Updates", "a", "conversation", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L724-L731
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.listConversations
public ConversationList listConversations(final int offset, final int limit) throws UnauthorizedException, GeneralException { String url = CONVERSATIONS_BASE_URL + CONVERSATION_PATH; return messageBirdService.requestList(url, offset, limit, ConversationList.class); }
java
public ConversationList listConversations(final int offset, final int limit) throws UnauthorizedException, GeneralException { String url = CONVERSATIONS_BASE_URL + CONVERSATION_PATH; return messageBirdService.requestList(url, offset, limit, ConversationList.class); }
[ "public", "ConversationList", "listConversations", "(", "final", "int", "offset", ",", "final", "int", "limit", ")", "throws", "UnauthorizedException", ",", "GeneralException", "{", "String", "url", "=", "CONVERSATIONS_BASE_URL", "+", "CONVERSATION_PATH", ";", "return...
Gets a Conversation listing with specified pagination options. @param offset Number of objects to skip. @param limit Number of objects to take. @return List of conversations.
[ "Gets", "a", "Conversation", "listing", "with", "specified", "pagination", "options", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L740-L744
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.startConversation
public Conversation startConversation(ConversationStartRequest request) throws UnauthorizedException, GeneralException { String url = String.format("%s%s/start", CONVERSATIONS_BASE_URL, CONVERSATION_PATH); return messageBirdService.sendPayLoad(url, request, Conversation.class); }
java
public Conversation startConversation(ConversationStartRequest request) throws UnauthorizedException, GeneralException { String url = String.format("%s%s/start", CONVERSATIONS_BASE_URL, CONVERSATION_PATH); return messageBirdService.sendPayLoad(url, request, Conversation.class); }
[ "public", "Conversation", "startConversation", "(", "ConversationStartRequest", "request", ")", "throws", "UnauthorizedException", ",", "GeneralException", "{", "String", "url", "=", "String", ".", "format", "(", "\"%s%s/start\"", ",", "CONVERSATIONS_BASE_URL", ",", "CO...
Starts a conversation by sending an initial message. @param request Data for this request. @return The created Conversation.
[ "Starts", "a", "conversation", "by", "sending", "an", "initial", "message", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L764-L768
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.listConversationMessages
public ConversationMessageList listConversationMessages( final String conversationId, final int offset, final int limit ) throws UnauthorizedException, GeneralException { String url = String.format( "%s%s/%s%s", CONVERSATIONS_BASE_URL, CONVERSATION_PATH, conversationId, CONVERSATION_MESSAGE_PATH ); return messageBirdService.requestList(url, offset, limit, ConversationMessageList.class); }
java
public ConversationMessageList listConversationMessages( final String conversationId, final int offset, final int limit ) throws UnauthorizedException, GeneralException { String url = String.format( "%s%s/%s%s", CONVERSATIONS_BASE_URL, CONVERSATION_PATH, conversationId, CONVERSATION_MESSAGE_PATH ); return messageBirdService.requestList(url, offset, limit, ConversationMessageList.class); }
[ "public", "ConversationMessageList", "listConversationMessages", "(", "final", "String", "conversationId", ",", "final", "int", "offset", ",", "final", "int", "limit", ")", "throws", "UnauthorizedException", ",", "GeneralException", "{", "String", "url", "=", "String"...
Gets a ConversationMessage listing with specified pagination options. @param conversationId Conversation to get messages for. @param offset Number of objects to skip. @param limit Number of objects to take. @return List of messages.
[ "Gets", "a", "ConversationMessage", "listing", "with", "specified", "pagination", "options", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L778-L791
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.listConversationMessages
public ConversationMessageList listConversationMessages( final String conversationId ) throws UnauthorizedException, GeneralException { final int offset = 0; final int limit = 10; return listConversationMessages(conversationId, offset, limit); }
java
public ConversationMessageList listConversationMessages( final String conversationId ) throws UnauthorizedException, GeneralException { final int offset = 0; final int limit = 10; return listConversationMessages(conversationId, offset, limit); }
[ "public", "ConversationMessageList", "listConversationMessages", "(", "final", "String", "conversationId", ")", "throws", "UnauthorizedException", ",", "GeneralException", "{", "final", "int", "offset", "=", "0", ";", "final", "int", "limit", "=", "10", ";", "return...
Gets a ConversationMessage listing with default pagination options. @param conversationId Conversation to get messages for. @return List of messages.
[ "Gets", "a", "ConversationMessage", "listing", "with", "default", "pagination", "options", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L799-L806
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.viewConversationMessage
public ConversationMessage viewConversationMessage(final String messageId) throws NotFoundException, GeneralException, UnauthorizedException { String url = CONVERSATIONS_BASE_URL + CONVERSATION_MESSAGE_PATH; return messageBirdService.requestByID(url, messageId, ConversationMessage.class); }
java
public ConversationMessage viewConversationMessage(final String messageId) throws NotFoundException, GeneralException, UnauthorizedException { String url = CONVERSATIONS_BASE_URL + CONVERSATION_MESSAGE_PATH; return messageBirdService.requestByID(url, messageId, ConversationMessage.class); }
[ "public", "ConversationMessage", "viewConversationMessage", "(", "final", "String", "messageId", ")", "throws", "NotFoundException", ",", "GeneralException", ",", "UnauthorizedException", "{", "String", "url", "=", "CONVERSATIONS_BASE_URL", "+", "CONVERSATION_MESSAGE_PATH", ...
Gets a single message. @param messageId Message to retrieve. @return The retrieved message.
[ "Gets", "a", "single", "message", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L814-L818
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.sendConversationMessage
public ConversationMessage sendConversationMessage( final String conversationId, final ConversationMessageRequest request ) throws UnauthorizedException, GeneralException { String url = String.format( "%s%s/%s%s", CONVERSATIONS_BASE_URL, CONVERSATION_PATH, conversationId, CONVERSATION_MESSAGE_PATH ); return messageBirdService.sendPayLoad(url, request, ConversationMessage.class); }
java
public ConversationMessage sendConversationMessage( final String conversationId, final ConversationMessageRequest request ) throws UnauthorizedException, GeneralException { String url = String.format( "%s%s/%s%s", CONVERSATIONS_BASE_URL, CONVERSATION_PATH, conversationId, CONVERSATION_MESSAGE_PATH ); return messageBirdService.sendPayLoad(url, request, ConversationMessage.class); }
[ "public", "ConversationMessage", "sendConversationMessage", "(", "final", "String", "conversationId", ",", "final", "ConversationMessageRequest", "request", ")", "throws", "UnauthorizedException", ",", "GeneralException", "{", "String", "url", "=", "String", ".", "format"...
Sends a message to an existing Conversation. @param conversationId Conversation to send message to. @param request Message to send. @return The newly created message.
[ "Sends", "a", "message", "to", "an", "existing", "Conversation", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L827-L839
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.deleteConversationWebhook
public void deleteConversationWebhook(final String webhookId) throws NotFoundException, GeneralException, UnauthorizedException { String url = CONVERSATIONS_BASE_URL + CONVERSATION_WEBHOOK_PATH; messageBirdService.deleteByID(url, webhookId); }
java
public void deleteConversationWebhook(final String webhookId) throws NotFoundException, GeneralException, UnauthorizedException { String url = CONVERSATIONS_BASE_URL + CONVERSATION_WEBHOOK_PATH; messageBirdService.deleteByID(url, webhookId); }
[ "public", "void", "deleteConversationWebhook", "(", "final", "String", "webhookId", ")", "throws", "NotFoundException", ",", "GeneralException", ",", "UnauthorizedException", "{", "String", "url", "=", "CONVERSATIONS_BASE_URL", "+", "CONVERSATION_WEBHOOK_PATH", ";", "mess...
Deletes a webhook. @param webhookId Webhook to delete.
[ "Deletes", "a", "webhook", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L846-L850
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.sendConversationWebhook
public ConversationWebhook sendConversationWebhook(final ConversationWebhookRequest request) throws UnauthorizedException, GeneralException { String url = CONVERSATIONS_BASE_URL + CONVERSATION_WEBHOOK_PATH; return messageBirdService.sendPayLoad(url, request, ConversationWebhook.class); }
java
public ConversationWebhook sendConversationWebhook(final ConversationWebhookRequest request) throws UnauthorizedException, GeneralException { String url = CONVERSATIONS_BASE_URL + CONVERSATION_WEBHOOK_PATH; return messageBirdService.sendPayLoad(url, request, ConversationWebhook.class); }
[ "public", "ConversationWebhook", "sendConversationWebhook", "(", "final", "ConversationWebhookRequest", "request", ")", "throws", "UnauthorizedException", ",", "GeneralException", "{", "String", "url", "=", "CONVERSATIONS_BASE_URL", "+", "CONVERSATION_WEBHOOK_PATH", ";", "ret...
Creates a new webhook. @param request Webhook to create. @return Newly created webhook.
[ "Creates", "a", "new", "webhook", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L858-L862
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.viewConversationWebhook
public ConversationWebhook viewConversationWebhook(final String webhookId) throws NotFoundException, GeneralException, UnauthorizedException { String url = CONVERSATIONS_BASE_URL + CONVERSATION_WEBHOOK_PATH; return messageBirdService.requestByID(url, webhookId, ConversationWebhook.class); }
java
public ConversationWebhook viewConversationWebhook(final String webhookId) throws NotFoundException, GeneralException, UnauthorizedException { String url = CONVERSATIONS_BASE_URL + CONVERSATION_WEBHOOK_PATH; return messageBirdService.requestByID(url, webhookId, ConversationWebhook.class); }
[ "public", "ConversationWebhook", "viewConversationWebhook", "(", "final", "String", "webhookId", ")", "throws", "NotFoundException", ",", "GeneralException", ",", "UnauthorizedException", "{", "String", "url", "=", "CONVERSATIONS_BASE_URL", "+", "CONVERSATION_WEBHOOK_PATH", ...
Gets a single webhook. @param webhookId Webhook to retrieve. @return The retrieved webhook.
[ "Gets", "a", "single", "webhook", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L870-L873
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.listConversationWebhooks
ConversationWebhookList listConversationWebhooks(final int offset, final int limit) throws UnauthorizedException, GeneralException { String url = CONVERSATIONS_BASE_URL + CONVERSATION_WEBHOOK_PATH; return messageBirdService.requestList(url, offset, limit, ConversationWebhookList.class); }
java
ConversationWebhookList listConversationWebhooks(final int offset, final int limit) throws UnauthorizedException, GeneralException { String url = CONVERSATIONS_BASE_URL + CONVERSATION_WEBHOOK_PATH; return messageBirdService.requestList(url, offset, limit, ConversationWebhookList.class); }
[ "ConversationWebhookList", "listConversationWebhooks", "(", "final", "int", "offset", ",", "final", "int", "limit", ")", "throws", "UnauthorizedException", ",", "GeneralException", "{", "String", "url", "=", "CONVERSATIONS_BASE_URL", "+", "CONVERSATION_WEBHOOK_PATH", ";",...
Gets a ConversationWebhook listing with the specified pagination options. @param offset Number of objects to skip. @param limit Number of objects to skip. @return List of webhooks.
[ "Gets", "a", "ConversationWebhook", "listing", "with", "the", "specified", "pagination", "options", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L882-L886
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.sendVoiceCall
public VoiceCallResponse sendVoiceCall(final VoiceCall voiceCall) throws UnauthorizedException, GeneralException { if (voiceCall.getSource() == null) { throw new IllegalArgumentException("Source of voice call must be specified."); } if (voiceCall.getDestination() == null) { throw new IllegalArgumentException("Destination of voice call must be specified."); } if (voiceCall.getCallFlow() == null) { throw new IllegalArgumentException("Call flow of voice call must be specified."); } String url = String.format("%s%s", VOICE_CALLS_BASE_URL, VOICECALLSPATH); return messageBirdService.sendPayLoad(url, voiceCall, VoiceCallResponse.class); }
java
public VoiceCallResponse sendVoiceCall(final VoiceCall voiceCall) throws UnauthorizedException, GeneralException { if (voiceCall.getSource() == null) { throw new IllegalArgumentException("Source of voice call must be specified."); } if (voiceCall.getDestination() == null) { throw new IllegalArgumentException("Destination of voice call must be specified."); } if (voiceCall.getCallFlow() == null) { throw new IllegalArgumentException("Call flow of voice call must be specified."); } String url = String.format("%s%s", VOICE_CALLS_BASE_URL, VOICECALLSPATH); return messageBirdService.sendPayLoad(url, voiceCall, VoiceCallResponse.class); }
[ "public", "VoiceCallResponse", "sendVoiceCall", "(", "final", "VoiceCall", "voiceCall", ")", "throws", "UnauthorizedException", ",", "GeneralException", "{", "if", "(", "voiceCall", ".", "getSource", "(", ")", "==", "null", ")", "{", "throw", "new", "IllegalArgume...
Function for voice call to a number @param voiceCall Voice call object @return VoiceCallResponse @throws UnauthorizedException if client is unauthorized @throws GeneralException general exception
[ "Function", "for", "voice", "call", "to", "a", "number" ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L912-L926
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.listAllVoiceCalls
public VoiceCallResponseList listAllVoiceCalls(Integer page, Integer pageSize) throws GeneralException, UnauthorizedException { String url = String.format("%s%s", VOICE_CALLS_BASE_URL, VOICECALLSPATH); return messageBirdService.requestList(url, new PagedPaging(page, pageSize), VoiceCallResponseList.class); }
java
public VoiceCallResponseList listAllVoiceCalls(Integer page, Integer pageSize) throws GeneralException, UnauthorizedException { String url = String.format("%s%s", VOICE_CALLS_BASE_URL, VOICECALLSPATH); return messageBirdService.requestList(url, new PagedPaging(page, pageSize), VoiceCallResponseList.class); }
[ "public", "VoiceCallResponseList", "listAllVoiceCalls", "(", "Integer", "page", ",", "Integer", "pageSize", ")", "throws", "GeneralException", ",", "UnauthorizedException", "{", "String", "url", "=", "String", ".", "format", "(", "\"%s%s\"", ",", "VOICE_CALLS_BASE_URL...
Function to list all voice calls @return VoiceCallResponseList @throws UnauthorizedException if client is unauthorized @throws GeneralException general exception
[ "Function", "to", "list", "all", "voice", "calls" ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L935-L938
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.viewVoiceCall
public VoiceCallResponse viewVoiceCall(final String id) throws NotFoundException, GeneralException, UnauthorizedException { if (id == null) { throw new IllegalArgumentException("Voice Message ID must be specified."); } String url = String.format("%s%s", VOICE_CALLS_BASE_URL, VOICECALLSPATH); return messageBirdService.requestByID(url, id, VoiceCallResponse.class); }
java
public VoiceCallResponse viewVoiceCall(final String id) throws NotFoundException, GeneralException, UnauthorizedException { if (id == null) { throw new IllegalArgumentException("Voice Message ID must be specified."); } String url = String.format("%s%s", VOICE_CALLS_BASE_URL, VOICECALLSPATH); return messageBirdService.requestByID(url, id, VoiceCallResponse.class); }
[ "public", "VoiceCallResponse", "viewVoiceCall", "(", "final", "String", "id", ")", "throws", "NotFoundException", ",", "GeneralException", ",", "UnauthorizedException", "{", "if", "(", "id", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", ...
Function to view voice call by id @param id Voice call ID @return VoiceCallResponse @throws UnauthorizedException if client is unauthorized @throws GeneralException general exception
[ "Function", "to", "view", "voice", "call", "by", "id" ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L948-L955
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.deleteVoiceCall
public void deleteVoiceCall(final String id) throws NotFoundException, GeneralException, UnauthorizedException { if (id == null) { throw new IllegalArgumentException("Voice Message ID must be specified."); } String url = String.format("%s%s", VOICE_CALLS_BASE_URL, VOICECALLSPATH); messageBirdService.deleteByID(url, id); }
java
public void deleteVoiceCall(final String id) throws NotFoundException, GeneralException, UnauthorizedException { if (id == null) { throw new IllegalArgumentException("Voice Message ID must be specified."); } String url = String.format("%s%s", VOICE_CALLS_BASE_URL, VOICECALLSPATH); messageBirdService.deleteByID(url, id); }
[ "public", "void", "deleteVoiceCall", "(", "final", "String", "id", ")", "throws", "NotFoundException", ",", "GeneralException", ",", "UnauthorizedException", "{", "if", "(", "id", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Voice Me...
Function to delete voice call by id @param id Voice call ID @throws UnauthorizedException if client is unauthorized @throws GeneralException general exception
[ "Function", "to", "delete", "voice", "call", "by", "id" ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L964-L971
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.viewCallLegsByCallId
public VoiceCallLegResponse viewCallLegsByCallId(String callId, Integer page, Integer pageSize) throws UnsupportedEncodingException, UnauthorizedException, GeneralException { if (callId == null) { throw new IllegalArgumentException("Voice call ID must be specified."); } String url = String.format( "%s%s/%s%s", VOICE_CALLS_BASE_URL, VOICECALLSPATH, urlEncode(callId), VOICELEGS_SUFFIX_PATH); return messageBirdService.requestList(url, new PagedPaging(page, pageSize), VoiceCallLegResponse.class); }
java
public VoiceCallLegResponse viewCallLegsByCallId(String callId, Integer page, Integer pageSize) throws UnsupportedEncodingException, UnauthorizedException, GeneralException { if (callId == null) { throw new IllegalArgumentException("Voice call ID must be specified."); } String url = String.format( "%s%s/%s%s", VOICE_CALLS_BASE_URL, VOICECALLSPATH, urlEncode(callId), VOICELEGS_SUFFIX_PATH); return messageBirdService.requestList(url, new PagedPaging(page, pageSize), VoiceCallLegResponse.class); }
[ "public", "VoiceCallLegResponse", "viewCallLegsByCallId", "(", "String", "callId", ",", "Integer", "page", ",", "Integer", "pageSize", ")", "throws", "UnsupportedEncodingException", ",", "UnauthorizedException", ",", "GeneralException", "{", "if", "(", "callId", "==", ...
Retrieves a listing of all legs. @param callId Voice call ID @param page page to fetch (can be null - will return first page), number of first page is 1 @param pageSize page size @return VoiceCallLegResponse @throws UnsupportedEncodingException no UTF8 supported url @throws UnauthorizedException if client is unauthorized @throws GeneralException general exception
[ "Retrieves", "a", "listing", "of", "all", "legs", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L984-L997
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.viewCallLegByCallIdAndLegId
public VoiceCallLeg viewCallLegByCallIdAndLegId(final String callId, String legId) throws UnsupportedEncodingException, NotFoundException, GeneralException, UnauthorizedException { if (callId == null) { throw new IllegalArgumentException("Voice call ID must be specified."); } if (legId == null) { throw new IllegalArgumentException("Leg ID must be specified."); } String url = String.format( "%s%s/%s%s", VOICE_CALLS_BASE_URL, VOICECALLSPATH, urlEncode(callId), VOICELEGS_SUFFIX_PATH); VoiceCallLegResponse response = messageBirdService.requestByID(url, legId, VoiceCallLegResponse.class); if (response.getData().size() == 1) { return response.getData().get(0); } else { throw new NotFoundException("No such leg", new LinkedList<ErrorReport>()); } }
java
public VoiceCallLeg viewCallLegByCallIdAndLegId(final String callId, String legId) throws UnsupportedEncodingException, NotFoundException, GeneralException, UnauthorizedException { if (callId == null) { throw new IllegalArgumentException("Voice call ID must be specified."); } if (legId == null) { throw new IllegalArgumentException("Leg ID must be specified."); } String url = String.format( "%s%s/%s%s", VOICE_CALLS_BASE_URL, VOICECALLSPATH, urlEncode(callId), VOICELEGS_SUFFIX_PATH); VoiceCallLegResponse response = messageBirdService.requestByID(url, legId, VoiceCallLegResponse.class); if (response.getData().size() == 1) { return response.getData().get(0); } else { throw new NotFoundException("No such leg", new LinkedList<ErrorReport>()); } }
[ "public", "VoiceCallLeg", "viewCallLegByCallIdAndLegId", "(", "final", "String", "callId", ",", "String", "legId", ")", "throws", "UnsupportedEncodingException", ",", "NotFoundException", ",", "GeneralException", ",", "UnauthorizedException", "{", "if", "(", "callId", "...
Retrieves a leg resource. The parameters are the unique ID of the call and of the leg that were returned upon their respective creation. @param callId Voice call ID @param legId ID of leg of specified call {callId} @return VoiceCallLeg @throws UnsupportedEncodingException no UTF8 supported url @throws NotFoundException not found with callId and legId @throws UnauthorizedException if client is unauthorized @throws GeneralException general exception
[ "Retrieves", "a", "leg", "resource", ".", "The", "parameters", "are", "the", "unique", "ID", "of", "the", "call", "and", "of", "the", "leg", "that", "were", "returned", "upon", "their", "respective", "creation", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L1011-L1034
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.createWebHook
public WebhookResponseData createWebHook(Webhook webhook) throws UnauthorizedException, GeneralException { if (webhook.getTitle() == null) { throw new IllegalArgumentException("Title of webhook must be specified."); } if (webhook.getUrl() == null) { throw new IllegalArgumentException("URL of webhook must be specified."); } String url = String.format("%s%s", VOICE_CALLS_BASE_URL, WEBHOOKS); return messageBirdService.sendPayLoad(url, webhook, WebhookResponseData.class); }
java
public WebhookResponseData createWebHook(Webhook webhook) throws UnauthorizedException, GeneralException { if (webhook.getTitle() == null) { throw new IllegalArgumentException("Title of webhook must be specified."); } if (webhook.getUrl() == null) { throw new IllegalArgumentException("URL of webhook must be specified."); } String url = String.format("%s%s", VOICE_CALLS_BASE_URL, WEBHOOKS); return messageBirdService.sendPayLoad(url, webhook, WebhookResponseData.class); }
[ "public", "WebhookResponseData", "createWebHook", "(", "Webhook", "webhook", ")", "throws", "UnauthorizedException", ",", "GeneralException", "{", "if", "(", "webhook", ".", "getTitle", "(", ")", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", ...
Function to create web hook @param webhook title, url and token of webHook @return WebHookResponseData @throws UnauthorizedException if client is unauthorized @throws GeneralException general exception
[ "Function", "to", "create", "web", "hook" ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L1164-L1175
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdClient.java
MessageBirdClient.viewWebHook
public WebhookResponseData viewWebHook(String id) throws NotFoundException, GeneralException, UnauthorizedException { if (id == null) { throw new IllegalArgumentException("Id of webHook must be specified."); } String url = String.format("%s%s", VOICE_CALLS_BASE_URL, WEBHOOKS); return messageBirdService.requestByID(url, id, WebhookResponseData.class); }
java
public WebhookResponseData viewWebHook(String id) throws NotFoundException, GeneralException, UnauthorizedException { if (id == null) { throw new IllegalArgumentException("Id of webHook must be specified."); } String url = String.format("%s%s", VOICE_CALLS_BASE_URL, WEBHOOKS); return messageBirdService.requestByID(url, id, WebhookResponseData.class); }
[ "public", "WebhookResponseData", "viewWebHook", "(", "String", "id", ")", "throws", "NotFoundException", ",", "GeneralException", ",", "UnauthorizedException", "{", "if", "(", "id", "==", "null", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Id of we...
Function to view webhook @param id webHook id @return WebHookResponseData @throws UnauthorizedException if client is unauthorized @throws GeneralException general exception
[ "Function", "to", "view", "webhook" ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdClient.java#L1185-L1192
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/RequestSigner.java
RequestSigner.computeSignature
private byte[] computeSignature(Request request) { String timestampAndQuery = request.getTimestamp() + '\n' + request.getSortedQueryParameters() + '\n'; byte[] timestampAndQueryBytes = timestampAndQuery.getBytes(CHARSET_UTF8); byte[] bodyHashBytes = getSha256Hash(request.getData()); return getHmacSha256Signature(appendArrays(timestampAndQueryBytes, bodyHashBytes)); }
java
private byte[] computeSignature(Request request) { String timestampAndQuery = request.getTimestamp() + '\n' + request.getSortedQueryParameters() + '\n'; byte[] timestampAndQueryBytes = timestampAndQuery.getBytes(CHARSET_UTF8); byte[] bodyHashBytes = getSha256Hash(request.getData()); return getHmacSha256Signature(appendArrays(timestampAndQueryBytes, bodyHashBytes)); }
[ "private", "byte", "[", "]", "computeSignature", "(", "Request", "request", ")", "{", "String", "timestampAndQuery", "=", "request", ".", "getTimestamp", "(", ")", "+", "'", "'", "+", "request", ".", "getSortedQueryParameters", "(", ")", "+", "'", "'", ";"...
Computes the signature for a request instance. @param request Request to compute signature for. @return HMAC-SHA2556 signature for the provided request.
[ "Computes", "the", "signature", "for", "a", "request", "instance", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/RequestSigner.java#L75-L83
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/RequestSigner.java
RequestSigner.appendArrays
private byte[] appendArrays(byte[] first, byte[] second) { byte[] result = new byte[first.length + second.length]; System.arraycopy(first, 0, result, 0, first.length); System.arraycopy(second, 0, result, first.length, second.length); return result; }
java
private byte[] appendArrays(byte[] first, byte[] second) { byte[] result = new byte[first.length + second.length]; System.arraycopy(first, 0, result, 0, first.length); System.arraycopy(second, 0, result, first.length, second.length); return result; }
[ "private", "byte", "[", "]", "appendArrays", "(", "byte", "[", "]", "first", ",", "byte", "[", "]", "second", ")", "{", "byte", "[", "]", "result", "=", "new", "byte", "[", "first", ".", "length", "+", "second", ".", "length", "]", ";", "System", ...
Stitches the two arrays together and returns a new one. @param first Start of the new array. @param second End of the new array. @return New array based on first and second.
[ "Stitches", "the", "two", "arrays", "together", "and", "returns", "a", "new", "one", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/RequestSigner.java#L100-L106
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdServiceImpl.java
MessageBirdServiceImpl.doRequest
<P> APIResponse doRequest(final String method, final String url, final P payload) throws GeneralException { HttpURLConnection connection = null; InputStream inputStream = null; if (METHOD_PATCH.equalsIgnoreCase(method)) { // It'd perhaps be cleaner to call this in the constructor, but // we'd then need to throw GeneralExceptions from there. This means // it wouldn't be possible to declare AND initialize _instance_ // fields of MessageBirdServiceImpl at the same time. This method // already throws this exception, so now we don't have to pollute // our public API further. allowPatchRequestsIfNeeded(); } try { connection = getConnection(url, payload, method); int status = connection.getResponseCode(); if (APIResponse.isSuccessStatus(status)) { inputStream = connection.getInputStream(); } else { inputStream = connection.getErrorStream(); } return new APIResponse(readToEnd(inputStream), status); } catch (IOException ioe) { throw new GeneralException(ioe); } finally { saveClose(inputStream); if (connection != null) { connection.disconnect(); } } }
java
<P> APIResponse doRequest(final String method, final String url, final P payload) throws GeneralException { HttpURLConnection connection = null; InputStream inputStream = null; if (METHOD_PATCH.equalsIgnoreCase(method)) { // It'd perhaps be cleaner to call this in the constructor, but // we'd then need to throw GeneralExceptions from there. This means // it wouldn't be possible to declare AND initialize _instance_ // fields of MessageBirdServiceImpl at the same time. This method // already throws this exception, so now we don't have to pollute // our public API further. allowPatchRequestsIfNeeded(); } try { connection = getConnection(url, payload, method); int status = connection.getResponseCode(); if (APIResponse.isSuccessStatus(status)) { inputStream = connection.getInputStream(); } else { inputStream = connection.getErrorStream(); } return new APIResponse(readToEnd(inputStream), status); } catch (IOException ioe) { throw new GeneralException(ioe); } finally { saveClose(inputStream); if (connection != null) { connection.disconnect(); } } }
[ "<", "P", ">", "APIResponse", "doRequest", "(", "final", "String", "method", ",", "final", "String", "url", ",", "final", "P", "payload", ")", "throws", "GeneralException", "{", "HttpURLConnection", "connection", "=", "null", ";", "InputStream", "inputStream", ...
Actually sends a HTTP request and returns its body and HTTP status code. @param method HTTP method. @param url Absolute URL. @param payload Payload to JSON encode for the request body. May be null. @param <P> Type of the payload. @return APIResponse containing the response's body and status.
[ "Actually", "sends", "a", "HTTP", "request", "and", "returns", "its", "body", "and", "HTTP", "status", "code", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdServiceImpl.java#L219-L253
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdServiceImpl.java
MessageBirdServiceImpl.getAllowedMethods
private static String[] getAllowedMethods(String[] existingMethods) { int listCapacity = existingMethods.length + 1; List<String> allowedMethods = new ArrayList<>(listCapacity); allowedMethods.addAll(Arrays.asList(existingMethods)); allowedMethods.add(METHOD_PATCH); return allowedMethods.toArray(new String[0]); }
java
private static String[] getAllowedMethods(String[] existingMethods) { int listCapacity = existingMethods.length + 1; List<String> allowedMethods = new ArrayList<>(listCapacity); allowedMethods.addAll(Arrays.asList(existingMethods)); allowedMethods.add(METHOD_PATCH); return allowedMethods.toArray(new String[0]); }
[ "private", "static", "String", "[", "]", "getAllowedMethods", "(", "String", "[", "]", "existingMethods", ")", "{", "int", "listCapacity", "=", "existingMethods", ".", "length", "+", "1", ";", "List", "<", "String", ">", "allowedMethods", "=", "new", "ArrayL...
Appends PATCH to the provided array. @param existingMethods Methods that are, and must be, allowed. @return New array also containing PATCH.
[ "Appends", "PATCH", "to", "the", "provided", "array", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdServiceImpl.java#L298-L307
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdServiceImpl.java
MessageBirdServiceImpl.readToEnd
private String readToEnd(InputStream inputStream) { Scanner scanner = new Scanner(inputStream).useDelimiter("\\A"); return scanner.hasNext() ? scanner.next() : ""; }
java
private String readToEnd(InputStream inputStream) { Scanner scanner = new Scanner(inputStream).useDelimiter("\\A"); return scanner.hasNext() ? scanner.next() : ""; }
[ "private", "String", "readToEnd", "(", "InputStream", "inputStream", ")", "{", "Scanner", "scanner", "=", "new", "Scanner", "(", "inputStream", ")", ".", "useDelimiter", "(", "\"\\\\A\"", ")", ";", "return", "scanner", ".", "hasNext", "(", ")", "?", "scanner...
Reads the stream until it has no more bytes and returns a UTF-8 encoded string representation. @param inputStream Stream to read from. @return UTF-8 encoded string representation of stream's contents.
[ "Reads", "the", "stream", "until", "it", "has", "no", "more", "bytes", "and", "returns", "a", "UTF", "-", "8", "encoded", "string", "representation", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdServiceImpl.java#L316-L320
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdServiceImpl.java
MessageBirdServiceImpl.isURLAbsolute
private boolean isURLAbsolute(String url) { for (String protocol : PROTOCOLS) { if (url.startsWith(protocol)) { return true; } } return false; }
java
private boolean isURLAbsolute(String url) { for (String protocol : PROTOCOLS) { if (url.startsWith(protocol)) { return true; } } return false; }
[ "private", "boolean", "isURLAbsolute", "(", "String", "url", ")", "{", "for", "(", "String", "protocol", ":", "PROTOCOLS", ")", "{", "if", "(", "url", ".", "startsWith", "(", "protocol", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false"...
Attempts determining whether the provided URL is an absolute one, based on the scheme. @param url provided url @return boolean
[ "Attempts", "determining", "whether", "the", "provided", "URL", "is", "an", "absolute", "one", "based", "on", "the", "scheme", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdServiceImpl.java#L328-L336
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdServiceImpl.java
MessageBirdServiceImpl.getConnection
public <P> HttpURLConnection getConnection(final String serviceUrl, final P postData, final String requestType) throws IOException { if (requestType == null || !REQUEST_METHODS.contains(requestType)) { throw new IllegalArgumentException(String.format(REQUEST_METHOD_NOT_ALLOWED, requestType)); } if (postData == null && "POST".equals(requestType)) { throw new IllegalArgumentException("POST detected without a payload, please supply a payload with a POST request"); } final URL restService = new URL(serviceUrl); final HttpURLConnection connection; if (proxy != null) { connection = (HttpURLConnection) restService.openConnection(proxy); } else { connection = (HttpURLConnection) restService.openConnection(); } connection.setDoInput(true); connection.setRequestProperty("Accept", "application/json"); connection.setUseCaches(false); connection.setRequestProperty("charset", "utf-8"); connection.setRequestProperty("Connection", "close"); connection.setRequestProperty("Authorization", "AccessKey " + accessKey); connection.setRequestProperty("User-agent", userAgentString); if ("POST".equals(requestType) || "PATCH".equals(requestType)) { connection.setRequestMethod(requestType); connection.setDoOutput(true); connection.setRequestProperty("Content-Type", "application/json"); ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(Include.NON_NULL); // Specifically set the date format for POST requests so scheduled // messages and other things relying on specific date formats don't // fail when sending. DateFormat df = getDateFormat(); mapper.setDateFormat(df); final String json = mapper.writeValueAsString(postData); connection.getOutputStream().write(json.getBytes(String.valueOf(StandardCharsets.UTF_8))); } else if ("DELETE".equals(requestType)) { // could have just used rquestType as it is connection.setDoOutput(false); connection.setRequestMethod("DELETE"); connection.setRequestProperty("Content-Type", "text/plain"); } else { connection.setDoOutput(false); connection.setRequestMethod("GET"); connection.setRequestProperty("Content-Type", "text/plain"); } return connection; }
java
public <P> HttpURLConnection getConnection(final String serviceUrl, final P postData, final String requestType) throws IOException { if (requestType == null || !REQUEST_METHODS.contains(requestType)) { throw new IllegalArgumentException(String.format(REQUEST_METHOD_NOT_ALLOWED, requestType)); } if (postData == null && "POST".equals(requestType)) { throw new IllegalArgumentException("POST detected without a payload, please supply a payload with a POST request"); } final URL restService = new URL(serviceUrl); final HttpURLConnection connection; if (proxy != null) { connection = (HttpURLConnection) restService.openConnection(proxy); } else { connection = (HttpURLConnection) restService.openConnection(); } connection.setDoInput(true); connection.setRequestProperty("Accept", "application/json"); connection.setUseCaches(false); connection.setRequestProperty("charset", "utf-8"); connection.setRequestProperty("Connection", "close"); connection.setRequestProperty("Authorization", "AccessKey " + accessKey); connection.setRequestProperty("User-agent", userAgentString); if ("POST".equals(requestType) || "PATCH".equals(requestType)) { connection.setRequestMethod(requestType); connection.setDoOutput(true); connection.setRequestProperty("Content-Type", "application/json"); ObjectMapper mapper = new ObjectMapper(); mapper.setSerializationInclusion(Include.NON_NULL); // Specifically set the date format for POST requests so scheduled // messages and other things relying on specific date formats don't // fail when sending. DateFormat df = getDateFormat(); mapper.setDateFormat(df); final String json = mapper.writeValueAsString(postData); connection.getOutputStream().write(json.getBytes(String.valueOf(StandardCharsets.UTF_8))); } else if ("DELETE".equals(requestType)) { // could have just used rquestType as it is connection.setDoOutput(false); connection.setRequestMethod("DELETE"); connection.setRequestProperty("Content-Type", "text/plain"); } else { connection.setDoOutput(false); connection.setRequestMethod("GET"); connection.setRequestProperty("Content-Type", "text/plain"); } return connection; }
[ "public", "<", "P", ">", "HttpURLConnection", "getConnection", "(", "final", "String", "serviceUrl", ",", "final", "P", "postData", ",", "final", "String", "requestType", ")", "throws", "IOException", "{", "if", "(", "requestType", "==", "null", "||", "!", "...
Create a HttpURLConnection connection object @param serviceUrl URL that needs to be requested @param postData PostDATA, must be not null for requestType is POST @param requestType Request type POST requests without a payload will generate a exception @return base class @throws IOException io exception
[ "Create", "a", "HttpURLConnection", "connection", "object" ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdServiceImpl.java#L347-L398
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdServiceImpl.java
MessageBirdServiceImpl.getErrorReportOrNull
private List<ErrorReport> getErrorReportOrNull(final String body) { ObjectMapper objectMapper = new ObjectMapper(); try { JsonNode jsonNode = objectMapper.readValue(body, JsonNode.class); ErrorReport[] errors = objectMapper.readValue(jsonNode.get("errors").toString(), ErrorReport[].class); List<ErrorReport> result = Arrays.asList(errors); if (result.isEmpty()) { return null; } return result; } catch (IOException e) { return null; } }
java
private List<ErrorReport> getErrorReportOrNull(final String body) { ObjectMapper objectMapper = new ObjectMapper(); try { JsonNode jsonNode = objectMapper.readValue(body, JsonNode.class); ErrorReport[] errors = objectMapper.readValue(jsonNode.get("errors").toString(), ErrorReport[].class); List<ErrorReport> result = Arrays.asList(errors); if (result.isEmpty()) { return null; } return result; } catch (IOException e) { return null; } }
[ "private", "List", "<", "ErrorReport", ">", "getErrorReportOrNull", "(", "final", "String", "body", ")", "{", "ObjectMapper", "objectMapper", "=", "new", "ObjectMapper", "(", ")", ";", "try", "{", "JsonNode", "jsonNode", "=", "objectMapper", ".", "readValue", ...
Get the MessageBird error report data. @param body Raw request body. @return Error report, or null if the body can not be deserialized.
[ "Get", "the", "MessageBird", "error", "report", "data", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdServiceImpl.java#L435-L452
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/MessageBirdServiceImpl.java
MessageBirdServiceImpl.getPathVariables
private String getPathVariables(final Map<String, Object> map) { final StringBuilder bpath = new StringBuilder(); for (Map.Entry<String, Object> param : map.entrySet()) { if (bpath.length() > 1) { bpath.append("&"); } try { bpath.append(URLEncoder.encode(param.getKey(), String.valueOf(StandardCharsets.UTF_8))).append("=").append(URLEncoder.encode(String.valueOf(param.getValue()), String.valueOf(StandardCharsets.UTF_8))); } catch (UnsupportedEncodingException exception) { // Do nothing } } return bpath.toString(); }
java
private String getPathVariables(final Map<String, Object> map) { final StringBuilder bpath = new StringBuilder(); for (Map.Entry<String, Object> param : map.entrySet()) { if (bpath.length() > 1) { bpath.append("&"); } try { bpath.append(URLEncoder.encode(param.getKey(), String.valueOf(StandardCharsets.UTF_8))).append("=").append(URLEncoder.encode(String.valueOf(param.getValue()), String.valueOf(StandardCharsets.UTF_8))); } catch (UnsupportedEncodingException exception) { // Do nothing } } return bpath.toString(); }
[ "private", "String", "getPathVariables", "(", "final", "Map", "<", "String", ",", "Object", ">", "map", ")", "{", "final", "StringBuilder", "bpath", "=", "new", "StringBuilder", "(", ")", ";", "for", "(", "Map", ".", "Entry", "<", "String", ",", "Object"...
Build a path variable for GET requests @param map map for getting path variables @return String
[ "Build", "a", "path", "variable", "for", "GET", "requests" ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/MessageBirdServiceImpl.java#L532-L545
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/objects/Message.java
Message.setPremiumSMS
public void setPremiumSMS(Object shortcode, Object keyword, Object tariff, Object mid) { final Map<String, Object> premiumSMSConfig = new LinkedHashMap<String, Object>(4); premiumSMSConfig.put("shortcode", shortcode); premiumSMSConfig.put("keyword", keyword); premiumSMSConfig.put("tariff", tariff); premiumSMSConfig.put("mid", mid); this.typeDetails = premiumSMSConfig; this.type = MsgType.premium; }
java
public void setPremiumSMS(Object shortcode, Object keyword, Object tariff, Object mid) { final Map<String, Object> premiumSMSConfig = new LinkedHashMap<String, Object>(4); premiumSMSConfig.put("shortcode", shortcode); premiumSMSConfig.put("keyword", keyword); premiumSMSConfig.put("tariff", tariff); premiumSMSConfig.put("mid", mid); this.typeDetails = premiumSMSConfig; this.type = MsgType.premium; }
[ "public", "void", "setPremiumSMS", "(", "Object", "shortcode", ",", "Object", "keyword", ",", "Object", "tariff", ",", "Object", "mid", ")", "{", "final", "Map", "<", "String", ",", "Object", ">", "premiumSMSConfig", "=", "new", "LinkedHashMap", "<", "String...
Setup premium SMS type @param shortcode @param keyword @param tariff @param mid
[ "Setup", "premium", "SMS", "type" ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/objects/Message.java#L298-L306
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/objects/conversations/ConversationHsmLocalizableParameter.java
ConversationHsmLocalizableParameter.defaultValue
public static ConversationHsmLocalizableParameter defaultValue(final String defaultValue) { ConversationHsmLocalizableParameter parameter = new ConversationHsmLocalizableParameter(); parameter.defaultValue = defaultValue; return parameter; }
java
public static ConversationHsmLocalizableParameter defaultValue(final String defaultValue) { ConversationHsmLocalizableParameter parameter = new ConversationHsmLocalizableParameter(); parameter.defaultValue = defaultValue; return parameter; }
[ "public", "static", "ConversationHsmLocalizableParameter", "defaultValue", "(", "final", "String", "defaultValue", ")", "{", "ConversationHsmLocalizableParameter", "parameter", "=", "new", "ConversationHsmLocalizableParameter", "(", ")", ";", "parameter", ".", "defaultValue",...
Gets a parameter that does a simple replacement without localization. @param defaultValue String to replace parameter with.
[ "Gets", "a", "parameter", "that", "does", "a", "simple", "replacement", "without", "localization", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/objects/conversations/ConversationHsmLocalizableParameter.java#L29-L34
train
messagebird/java-rest-api
api/src/main/java/com/messagebird/objects/conversations/ConversationHsmLocalizableParameter.java
ConversationHsmLocalizableParameter.currency
public static ConversationHsmLocalizableParameter currency(final String defaultValue, final String code, final int amount) { ConversationHsmLocalizableParameter parameter = new ConversationHsmLocalizableParameter(); parameter.defaultValue = defaultValue; parameter.currency = new ConversationHsmLocalizableParameterCurrency(code, amount); return parameter; }
java
public static ConversationHsmLocalizableParameter currency(final String defaultValue, final String code, final int amount) { ConversationHsmLocalizableParameter parameter = new ConversationHsmLocalizableParameter(); parameter.defaultValue = defaultValue; parameter.currency = new ConversationHsmLocalizableParameterCurrency(code, amount); return parameter; }
[ "public", "static", "ConversationHsmLocalizableParameter", "currency", "(", "final", "String", "defaultValue", ",", "final", "String", "code", ",", "final", "int", "amount", ")", "{", "ConversationHsmLocalizableParameter", "parameter", "=", "new", "ConversationHsmLocaliza...
Gets a parameter that localizes a currency. @param defaultValue Default for when localization fails. @param code ISO 4217 compliant currency code. @param amount Amount multiplied by 1000. E.g. 12.34 becomes 12340.
[ "Gets", "a", "parameter", "that", "localizes", "a", "currency", "." ]
f92cd93afff413e6dc12aa6e41e69f26cbae8941
https://github.com/messagebird/java-rest-api/blob/f92cd93afff413e6dc12aa6e41e69f26cbae8941/api/src/main/java/com/messagebird/objects/conversations/ConversationHsmLocalizableParameter.java#L43-L49
train
Moocar/logback-gelf
src/main/java/me/moocar/logbackgelf/InternetUtils.java
InternetUtils.getInetAddress
public static InetAddress getInetAddress(String hostName) { try { return InetAddress.getByName(hostName); } catch (UnknownHostException e) { throw new IllegalStateException("Unknown host: " + e.getMessage() + ". Make sure you have specified the 'GelfUDPAppender.remoteHost' property correctly in your logback.xml'"); } }
java
public static InetAddress getInetAddress(String hostName) { try { return InetAddress.getByName(hostName); } catch (UnknownHostException e) { throw new IllegalStateException("Unknown host: " + e.getMessage() + ". Make sure you have specified the 'GelfUDPAppender.remoteHost' property correctly in your logback.xml'"); } }
[ "public", "static", "InetAddress", "getInetAddress", "(", "String", "hostName", ")", "{", "try", "{", "return", "InetAddress", ".", "getByName", "(", "hostName", ")", ";", "}", "catch", "(", "UnknownHostException", "e", ")", "{", "throw", "new", "IllegalStateE...
Gets the Inet address for the GelfUDPAppender.remoteHost and gives a specialised error message if an exception is thrown @return The Inet address for GelfUDPAppender.remoteHost
[ "Gets", "the", "Inet", "address", "for", "the", "GelfUDPAppender", ".", "remoteHost", "and", "gives", "a", "specialised", "error", "message", "if", "an", "exception", "is", "thrown" ]
71dd32c7c417cb5c712b1f3d8b026ad624f2ae8d
https://github.com/Moocar/logback-gelf/blob/71dd32c7c417cb5c712b1f3d8b026ad624f2ae8d/src/main/java/me/moocar/logbackgelf/InternetUtils.java#L49-L56
train
Moocar/logback-gelf
src/main/java/me/moocar/logbackgelf/GelfLayout.java
GelfLayout.mapFields
private Map<String, Object> mapFields(E logEvent) { Map<String, Object> map = new HashMap<String, Object>(); map.put("host", host); map.put("full_message", fullMessageLayout.doLayout(logEvent)); map.put("short_message", shortMessageLayout.doLayout(logEvent)); stackTraceField(map, logEvent); map.put("timestamp", logEvent.getTimeStamp() / 1000.0); map.put("version", "1.1"); map.put("level", LevelToSyslogSeverity.convert(logEvent)); additionalFields(map, logEvent); staticAdditionalFields(map); return map; }
java
private Map<String, Object> mapFields(E logEvent) { Map<String, Object> map = new HashMap<String, Object>(); map.put("host", host); map.put("full_message", fullMessageLayout.doLayout(logEvent)); map.put("short_message", shortMessageLayout.doLayout(logEvent)); stackTraceField(map, logEvent); map.put("timestamp", logEvent.getTimeStamp() / 1000.0); map.put("version", "1.1"); map.put("level", LevelToSyslogSeverity.convert(logEvent)); additionalFields(map, logEvent); staticAdditionalFields(map); return map; }
[ "private", "Map", "<", "String", ",", "Object", ">", "mapFields", "(", "E", "logEvent", ")", "{", "Map", "<", "String", ",", "Object", ">", "map", "=", "new", "HashMap", "<", "String", ",", "Object", ">", "(", ")", ";", "map", ".", "put", "(", "\...
Creates a map of properties that represent the GELF message. @param logEvent The log event @return map of gelf properties
[ "Creates", "a", "map", "of", "properties", "that", "represent", "the", "GELF", "message", "." ]
71dd32c7c417cb5c712b1f3d8b026ad624f2ae8d
https://github.com/Moocar/logback-gelf/blob/71dd32c7c417cb5c712b1f3d8b026ad624f2ae8d/src/main/java/me/moocar/logbackgelf/GelfLayout.java#L100-L121
train
Moocar/logback-gelf
src/main/java/me/moocar/logbackgelf/GelfLayout.java
GelfLayout.additionalFields
private void additionalFields(Map<String, Object> map, ILoggingEvent eventObject) { if (useLoggerName) { map.put("_loggerName", eventObject.getLoggerName()); } if(useMarker && eventHasMarker(eventObject)) { map.put("_marker", eventObject.getMarker().toString()); } if (useThreadName) { map.put("_threadName", eventObject.getThreadName()); } Map<String, String> mdc = eventObject.getMDCPropertyMap(); if (mdc != null) { if (includeFullMDC) { for (Entry<String, String> e : mdc.entrySet()) { if (additionalFields.containsKey(e.getKey())) { map.put(additionalFields.get(e.getKey()), convertFieldType(e.getValue(), additionalFields.get(e.getKey()))); } else { map.put("_" + e.getKey(), convertFieldType(e.getValue(), "_" + e.getKey())); } } } else { for (String key : additionalFields.keySet()) { String field = mdc.get(key); if (field != null) { map.put(additionalFields.get(key), convertFieldType(field, key)); } } } } }
java
private void additionalFields(Map<String, Object> map, ILoggingEvent eventObject) { if (useLoggerName) { map.put("_loggerName", eventObject.getLoggerName()); } if(useMarker && eventHasMarker(eventObject)) { map.put("_marker", eventObject.getMarker().toString()); } if (useThreadName) { map.put("_threadName", eventObject.getThreadName()); } Map<String, String> mdc = eventObject.getMDCPropertyMap(); if (mdc != null) { if (includeFullMDC) { for (Entry<String, String> e : mdc.entrySet()) { if (additionalFields.containsKey(e.getKey())) { map.put(additionalFields.get(e.getKey()), convertFieldType(e.getValue(), additionalFields.get(e.getKey()))); } else { map.put("_" + e.getKey(), convertFieldType(e.getValue(), "_" + e.getKey())); } } } else { for (String key : additionalFields.keySet()) { String field = mdc.get(key); if (field != null) { map.put(additionalFields.get(key), convertFieldType(field, key)); } } } } }
[ "private", "void", "additionalFields", "(", "Map", "<", "String", ",", "Object", ">", "map", ",", "ILoggingEvent", "eventObject", ")", "{", "if", "(", "useLoggerName", ")", "{", "map", ".", "put", "(", "\"_loggerName\"", ",", "eventObject", ".", "getLoggerNa...
Converts the additional fields into proper GELF JSON @param map The map of additional fields @param eventObject The Logging event that we are converting to GELF
[ "Converts", "the", "additional", "fields", "into", "proper", "GELF", "JSON" ]
71dd32c7c417cb5c712b1f3d8b026ad624f2ae8d
https://github.com/Moocar/logback-gelf/blob/71dd32c7c417cb5c712b1f3d8b026ad624f2ae8d/src/main/java/me/moocar/logbackgelf/GelfLayout.java#L144-L179
train
Moocar/logback-gelf
src/main/java/me/moocar/logbackgelf/GelfLayout.java
GelfLayout.addAdditionalField
public void addAdditionalField(String keyValue) { String[] splitted = keyValue.split(":"); if (splitted.length != 2) { throw new IllegalArgumentException("additionalField must be of the format key:value, where key is the MDC " + "key, and value is the GELF field name. But found '" + keyValue + "' instead."); } additionalFields.put(splitted[0], splitted[1]); }
java
public void addAdditionalField(String keyValue) { String[] splitted = keyValue.split(":"); if (splitted.length != 2) { throw new IllegalArgumentException("additionalField must be of the format key:value, where key is the MDC " + "key, and value is the GELF field name. But found '" + keyValue + "' instead."); } additionalFields.put(splitted[0], splitted[1]); }
[ "public", "void", "addAdditionalField", "(", "String", "keyValue", ")", "{", "String", "[", "]", "splitted", "=", "keyValue", ".", "split", "(", "\":\"", ")", ";", "if", "(", "splitted", ".", "length", "!=", "2", ")", "{", "throw", "new", "IllegalArgumen...
Add an additional field. This is mainly here for compatibility with logback.xml @param keyValue This must be in format key:value where key is the MDC key, and value is the GELF field name. e.g "ipAddress:_ip_address"
[ "Add", "an", "additional", "field", ".", "This", "is", "mainly", "here", "for", "compatibility", "with", "logback", ".", "xml" ]
71dd32c7c417cb5c712b1f3d8b026ad624f2ae8d
https://github.com/Moocar/logback-gelf/blob/71dd32c7c417cb5c712b1f3d8b026ad624f2ae8d/src/main/java/me/moocar/logbackgelf/GelfLayout.java#L321-L331
train
Moocar/logback-gelf
src/main/java/me/moocar/logbackgelf/GelfLayout.java
GelfLayout.addStaticAdditionalField
public void addStaticAdditionalField(String keyValue) { String[] splitted = keyValue.split(":"); if (splitted.length != 2) { throw new IllegalArgumentException("staticAdditionalField must be of the format key:value, where key is the " + "additional field key (therefore should have a leading underscore), and value is a static string. " + "e.g. _node_name:www013"); } staticFields.put(splitted[0], splitted[1]); }
java
public void addStaticAdditionalField(String keyValue) { String[] splitted = keyValue.split(":"); if (splitted.length != 2) { throw new IllegalArgumentException("staticAdditionalField must be of the format key:value, where key is the " + "additional field key (therefore should have a leading underscore), and value is a static string. " + "e.g. _node_name:www013"); } staticFields.put(splitted[0], splitted[1]); }
[ "public", "void", "addStaticAdditionalField", "(", "String", "keyValue", ")", "{", "String", "[", "]", "splitted", "=", "keyValue", ".", "split", "(", "\":\"", ")", ";", "if", "(", "splitted", ".", "length", "!=", "2", ")", "{", "throw", "new", "IllegalA...
Add a staticAdditional field. This is mainly here for compatibility with logback.xml @param keyValue This must be in format key:value where key is the additional field key, and value is a static string. e.g "_node_name:www013" @deprecated Use addStaticField instead
[ "Add", "a", "staticAdditional", "field", ".", "This", "is", "mainly", "here", "for", "compatibility", "with", "logback", ".", "xml" ]
71dd32c7c417cb5c712b1f3d8b026ad624f2ae8d
https://github.com/Moocar/logback-gelf/blob/71dd32c7c417cb5c712b1f3d8b026ad624f2ae8d/src/main/java/me/moocar/logbackgelf/GelfLayout.java#L341-L352
train
Moocar/logback-gelf
src/main/java/me/moocar/logbackgelf/MessageIdProvider.java
MessageIdProvider.get
public byte[] get() { // Uniqueness is guaranteed by combining the hostname and the current nano second, hashing the result, and // selecting the first x bytes of the result String timestamp = String.valueOf(System.nanoTime()); byte[] digestString = (hostname + timestamp).getBytes(); return Arrays.copyOf(messageDigest.digest(digestString), messageIdLength); }
java
public byte[] get() { // Uniqueness is guaranteed by combining the hostname and the current nano second, hashing the result, and // selecting the first x bytes of the result String timestamp = String.valueOf(System.nanoTime()); byte[] digestString = (hostname + timestamp).getBytes(); return Arrays.copyOf(messageDigest.digest(digestString), messageIdLength); }
[ "public", "byte", "[", "]", "get", "(", ")", "{", "// Uniqueness is guaranteed by combining the hostname and the current nano second, hashing the result, and", "// selecting the first x bytes of the result", "String", "timestamp", "=", "String", ".", "valueOf", "(", "System", "."...
Creates a message id that should be unique on every call. The message ID needs to be unique for every message. If a message is chunked, then each chunk in a message needs the same message ID. @return unique message ID
[ "Creates", "a", "message", "id", "that", "should", "be", "unique", "on", "every", "call", ".", "The", "message", "ID", "needs", "to", "be", "unique", "for", "every", "message", ".", "If", "a", "message", "is", "chunked", "then", "each", "chunk", "in", ...
71dd32c7c417cb5c712b1f3d8b026ad624f2ae8d
https://github.com/Moocar/logback-gelf/blob/71dd32c7c417cb5c712b1f3d8b026ad624f2ae8d/src/main/java/me/moocar/logbackgelf/MessageIdProvider.java#L33-L42
train
bremersee/comparator
src/main/java/org/bremersee/comparator/ObjectComparatorFactory.java
ObjectComparatorFactory.newInstance
public static ObjectComparatorFactory newInstance( final String objectComparatorFactoryClassName) throws InstantiationException, IllegalAccessException, ClassNotFoundException { return (ObjectComparatorFactory) Class.forName(objectComparatorFactoryClassName).newInstance(); }
java
public static ObjectComparatorFactory newInstance( final String objectComparatorFactoryClassName) throws InstantiationException, IllegalAccessException, ClassNotFoundException { return (ObjectComparatorFactory) Class.forName(objectComparatorFactoryClassName).newInstance(); }
[ "public", "static", "ObjectComparatorFactory", "newInstance", "(", "final", "String", "objectComparatorFactoryClassName", ")", "throws", "InstantiationException", ",", "IllegalAccessException", ",", "ClassNotFoundException", "{", "return", "(", "ObjectComparatorFactory", ")", ...
Create a new instance of a the specified factory class. @param objectComparatorFactoryClassName the factory class @return a new instance of a the specified factory @throws InstantiationException if creation of the factory fails @throws IllegalAccessException if creation of the factory fails @throws ClassNotFoundException if creation of the factory fails
[ "Create", "a", "new", "instance", "of", "a", "the", "specified", "factory", "class", "." ]
6958e6e28a62589106705062f8ffc201a87d9b2a
https://github.com/bremersee/comparator/blob/6958e6e28a62589106705062f8ffc201a87d9b2a/src/main/java/org/bremersee/comparator/ObjectComparatorFactory.java#L47-L51
train
bremersee/comparator
src/main/java/org/bremersee/comparator/ObjectComparatorFactory.java
ObjectComparatorFactory.newInstance
public static ObjectComparatorFactory newInstance(final String objectComparatorFactoryClassName, final ClassLoader classLoader) throws InstantiationException, IllegalAccessException, ClassNotFoundException { return (ObjectComparatorFactory) Class .forName(objectComparatorFactoryClassName, true, classLoader) .newInstance(); }
java
public static ObjectComparatorFactory newInstance(final String objectComparatorFactoryClassName, final ClassLoader classLoader) throws InstantiationException, IllegalAccessException, ClassNotFoundException { return (ObjectComparatorFactory) Class .forName(objectComparatorFactoryClassName, true, classLoader) .newInstance(); }
[ "public", "static", "ObjectComparatorFactory", "newInstance", "(", "final", "String", "objectComparatorFactoryClassName", ",", "final", "ClassLoader", "classLoader", ")", "throws", "InstantiationException", ",", "IllegalAccessException", ",", "ClassNotFoundException", "{", "r...
Create a new instance of a the specified factory class by using the specified class loader. @param objectComparatorFactoryClassName the factory class @param classLoader the class loader @return a new instance of a the specified factory @throws InstantiationException if creation of the factory fails @throws IllegalAccessException if creation of the factory fails @throws ClassNotFoundException if creation of the factory fails
[ "Create", "a", "new", "instance", "of", "a", "the", "specified", "factory", "class", "by", "using", "the", "specified", "class", "loader", "." ]
6958e6e28a62589106705062f8ffc201a87d9b2a
https://github.com/bremersee/comparator/blob/6958e6e28a62589106705062f8ffc201a87d9b2a/src/main/java/org/bremersee/comparator/ObjectComparatorFactory.java#L63-L69
train
attribyte/acp
src/main/java/org/attribyte/sql/pool/ConnectionPoolSegment.java
ConnectionPoolSegment.defaultInitializer
public static Initializer defaultInitializer() { return newInitializer() .setCloseConcurrency(0) .setTestOnLogicalOpen(false) .setTestOnLogicalClose(false) .setIncompleteTransactionOnClosePolicy(ConnectionPoolConnection.IncompleteTransactionPolicy.REPORT) .setOpenStatementOnClosePolicy(ConnectionPoolConnection.OpenStatementPolicy.REPORT) .setForceRealClosePolicy(ConnectionPoolConnection.ForceRealClosePolicy.CONNECTION_WITH_LIMIT) .setActivityTimeoutPolicy(ConnectionPoolConnection.ActivityTimeoutPolicy.LOG) .setCloseTimeLimitMillis(10 * 1000L) .setActiveTimeout(60, TimeUnit.SECONDS) .setConnectionLifetime(15, TimeUnit.MINUTES) .setMaxConcurrentReconnects(2) .setMaxReconnectDelay(1, TimeUnit.MINUTES) .setActiveTimeoutMonitorFrequency(30, TimeUnit.SECONDS); }
java
public static Initializer defaultInitializer() { return newInitializer() .setCloseConcurrency(0) .setTestOnLogicalOpen(false) .setTestOnLogicalClose(false) .setIncompleteTransactionOnClosePolicy(ConnectionPoolConnection.IncompleteTransactionPolicy.REPORT) .setOpenStatementOnClosePolicy(ConnectionPoolConnection.OpenStatementPolicy.REPORT) .setForceRealClosePolicy(ConnectionPoolConnection.ForceRealClosePolicy.CONNECTION_WITH_LIMIT) .setActivityTimeoutPolicy(ConnectionPoolConnection.ActivityTimeoutPolicy.LOG) .setCloseTimeLimitMillis(10 * 1000L) .setActiveTimeout(60, TimeUnit.SECONDS) .setConnectionLifetime(15, TimeUnit.MINUTES) .setMaxConcurrentReconnects(2) .setMaxReconnectDelay(1, TimeUnit.MINUTES) .setActiveTimeoutMonitorFrequency(30, TimeUnit.SECONDS); }
[ "public", "static", "Initializer", "defaultInitializer", "(", ")", "{", "return", "newInitializer", "(", ")", ".", "setCloseConcurrency", "(", "0", ")", ".", "setTestOnLogicalOpen", "(", "false", ")", ".", "setTestOnLogicalClose", "(", "false", ")", ".", "setInc...
Creates a segment initializer with default values. @return The segment initializer with default values.
[ "Creates", "a", "segment", "initializer", "with", "default", "values", "." ]
dbee6ebb83fda4f19fbbbcb9d0ac2b527e3cb659
https://github.com/attribyte/acp/blob/dbee6ebb83fda4f19fbbbcb9d0ac2b527e3cb659/src/main/java/org/attribyte/sql/pool/ConnectionPoolSegment.java#L225-L240
train
attribyte/acp
src/main/java/org/attribyte/sql/pool/ConnectionPoolSegment.java
ConnectionPoolSegment.reopen
private void reopen(final ConnectionPoolConnection conn) { if(isActive) { if(conn.reopenAttempts == 0) { conn.reopenAttempts++; reopenService.execute(new Reopener(conn)); } else { long delayMillis = 100L * conn.reopenAttempts; if(delayMillis > maxReconnectDelayMillis) { delayMillis = maxReconnectDelayMillis; } conn.reopenAttempts++; reopenService.schedule(new Reopener(conn), delayMillis, TimeUnit.MILLISECONDS); } } }
java
private void reopen(final ConnectionPoolConnection conn) { if(isActive) { if(conn.reopenAttempts == 0) { conn.reopenAttempts++; reopenService.execute(new Reopener(conn)); } else { long delayMillis = 100L * conn.reopenAttempts; if(delayMillis > maxReconnectDelayMillis) { delayMillis = maxReconnectDelayMillis; } conn.reopenAttempts++; reopenService.schedule(new Reopener(conn), delayMillis, TimeUnit.MILLISECONDS); } } }
[ "private", "void", "reopen", "(", "final", "ConnectionPoolConnection", "conn", ")", "{", "if", "(", "isActive", ")", "{", "if", "(", "conn", ".", "reopenAttempts", "==", "0", ")", "{", "conn", ".", "reopenAttempts", "++", ";", "reopenService", ".", "execut...
Schedule connection reopen. @param conn The connection.
[ "Schedule", "connection", "reopen", "." ]
dbee6ebb83fda4f19fbbbcb9d0ac2b527e3cb659
https://github.com/attribyte/acp/blob/dbee6ebb83fda4f19fbbbcb9d0ac2b527e3cb659/src/main/java/org/attribyte/sql/pool/ConnectionPoolSegment.java#L722-L737
train
attribyte/acp
src/main/java/org/attribyte/sql/pool/ConnectionPoolSegment.java
ConnectionPoolSegment.close
final void close(final ConnectionPoolConnection conn) { if(closeQueue != null) { closeQueue.add(conn); } else { closer.close(conn); } }
java
final void close(final ConnectionPoolConnection conn) { if(closeQueue != null) { closeQueue.add(conn); } else { closer.close(conn); } }
[ "final", "void", "close", "(", "final", "ConnectionPoolConnection", "conn", ")", "{", "if", "(", "closeQueue", "!=", "null", ")", "{", "closeQueue", ".", "add", "(", "conn", ")", ";", "}", "else", "{", "closer", ".", "close", "(", "conn", ")", ";", "...
Adds a connection to the close queue. @param conn The connection.
[ "Adds", "a", "connection", "to", "the", "close", "queue", "." ]
dbee6ebb83fda4f19fbbbcb9d0ac2b527e3cb659
https://github.com/attribyte/acp/blob/dbee6ebb83fda4f19fbbbcb9d0ac2b527e3cb659/src/main/java/org/attribyte/sql/pool/ConnectionPoolSegment.java#L923-L929
train
attribyte/acp
src/main/java/org/attribyte/sql/pool/ConnectionPoolSegment.java
ConnectionPoolSegment.getPassword
final String getPassword() { if(passwordSource == null) { return dbConnection.password; } else { String usePassword = passwordSource.getPassword(dbConnection.name); if(!Strings.isNullOrEmpty(usePassword)) { return usePassword; } else { usePassword = passwordSource.getPassword(dbConnection.connectionString, dbConnection.user); return !Strings.isNullOrEmpty(usePassword) ? usePassword : dbConnection.password; } } }
java
final String getPassword() { if(passwordSource == null) { return dbConnection.password; } else { String usePassword = passwordSource.getPassword(dbConnection.name); if(!Strings.isNullOrEmpty(usePassword)) { return usePassword; } else { usePassword = passwordSource.getPassword(dbConnection.connectionString, dbConnection.user); return !Strings.isNullOrEmpty(usePassword) ? usePassword : dbConnection.password; } } }
[ "final", "String", "getPassword", "(", ")", "{", "if", "(", "passwordSource", "==", "null", ")", "{", "return", "dbConnection", ".", "password", ";", "}", "else", "{", "String", "usePassword", "=", "passwordSource", ".", "getPassword", "(", "dbConnection", "...
Gets the password for connection creation. @return The password.
[ "Gets", "the", "password", "for", "connection", "creation", "." ]
dbee6ebb83fda4f19fbbbcb9d0ac2b527e3cb659
https://github.com/attribyte/acp/blob/dbee6ebb83fda4f19fbbbcb9d0ac2b527e3cb659/src/main/java/org/attribyte/sql/pool/ConnectionPoolSegment.java#L1159-L1171
train
attribyte/acp
src/main/java/org/attribyte/sql/pool/ConnectionPoolSegment.java
ConnectionPoolSegment.createRealConnection
private Connection createRealConnection(final long timeoutMillis) throws SQLException { if(timeoutMillis < 1L) { String usePassword = getPassword(); Connection conn = dbConnection.datasource == null ? DriverManager.getConnection(dbConnection.connectionString, dbConnection.user, usePassword) : dbConnection.datasource.getConnection(dbConnection.user, usePassword); if(conn != null) { return conn; } else { throw new SQLException("Unable to create connection: driver/datasource returned [null]"); } } else { try { return connectionTimeLimiter.callWithTimeout(() -> createRealConnection(0L), timeoutMillis, TimeUnit.MILLISECONDS); } catch(UncheckedTimeoutException ute) { throw new SQLException("Unable to create connection after waiting " + timeoutMillis + " ms"); } catch(Exception e) { throw new SQLException("Unable to create connection: driver/datasource", e); } } }
java
private Connection createRealConnection(final long timeoutMillis) throws SQLException { if(timeoutMillis < 1L) { String usePassword = getPassword(); Connection conn = dbConnection.datasource == null ? DriverManager.getConnection(dbConnection.connectionString, dbConnection.user, usePassword) : dbConnection.datasource.getConnection(dbConnection.user, usePassword); if(conn != null) { return conn; } else { throw new SQLException("Unable to create connection: driver/datasource returned [null]"); } } else { try { return connectionTimeLimiter.callWithTimeout(() -> createRealConnection(0L), timeoutMillis, TimeUnit.MILLISECONDS); } catch(UncheckedTimeoutException ute) { throw new SQLException("Unable to create connection after waiting " + timeoutMillis + " ms"); } catch(Exception e) { throw new SQLException("Unable to create connection: driver/datasource", e); } } }
[ "private", "Connection", "createRealConnection", "(", "final", "long", "timeoutMillis", ")", "throws", "SQLException", "{", "if", "(", "timeoutMillis", "<", "1L", ")", "{", "String", "usePassword", "=", "getPassword", "(", ")", ";", "Connection", "conn", "=", ...
Creates a real database connection, failing if one is not obtained in the specified time. @param timeoutMillis The timeout in milliseconds. @return The connection. @throws SQLException on connection problem or timeout waiting for connection.
[ "Creates", "a", "real", "database", "connection", "failing", "if", "one", "is", "not", "obtained", "in", "the", "specified", "time", "." ]
dbee6ebb83fda4f19fbbbcb9d0ac2b527e3cb659
https://github.com/attribyte/acp/blob/dbee6ebb83fda4f19fbbbcb9d0ac2b527e3cb659/src/main/java/org/attribyte/sql/pool/ConnectionPoolSegment.java#L1179-L1204
train
attribyte/acp
src/main/java/org/attribyte/sql/pool/ConnectionPoolSegment.java
ConnectionPoolSegment.activate
final void activate() throws SQLException { for(ConnectionPoolConnection conn : connections) { conn.forceRealClose(); conn.realOpen(); conn.logicalClose(true); //Tests the connection } if(closeQueue != null) { closeQueue.clear(); } availableQueue.clear(); reopenExecutor.getQueue().clear(); List<ConnectionPoolConnection> connections = Lists.newArrayListWithCapacity(this.connections.length); for(ConnectionPoolConnection connection : this.connections) { connections.add(connection); connection.state.set(ConnectionPoolConnection.STATE_AVAILABLE); } isActive = true; stats.activate(); availableQueue.addAll(connections); }
java
final void activate() throws SQLException { for(ConnectionPoolConnection conn : connections) { conn.forceRealClose(); conn.realOpen(); conn.logicalClose(true); //Tests the connection } if(closeQueue != null) { closeQueue.clear(); } availableQueue.clear(); reopenExecutor.getQueue().clear(); List<ConnectionPoolConnection> connections = Lists.newArrayListWithCapacity(this.connections.length); for(ConnectionPoolConnection connection : this.connections) { connections.add(connection); connection.state.set(ConnectionPoolConnection.STATE_AVAILABLE); } isActive = true; stats.activate(); availableQueue.addAll(connections); }
[ "final", "void", "activate", "(", ")", "throws", "SQLException", "{", "for", "(", "ConnectionPoolConnection", "conn", ":", "connections", ")", "{", "conn", ".", "forceRealClose", "(", ")", ";", "conn", ".", "realOpen", "(", ")", ";", "conn", ".", "logicalC...
Activates the segment by opening and testing all connections. @throws SQLException if connections could not be created.
[ "Activates", "the", "segment", "by", "opening", "and", "testing", "all", "connections", "." ]
dbee6ebb83fda4f19fbbbcb9d0ac2b527e3cb659
https://github.com/attribyte/acp/blob/dbee6ebb83fda4f19fbbbcb9d0ac2b527e3cb659/src/main/java/org/attribyte/sql/pool/ConnectionPoolSegment.java#L1210-L1233
train
attribyte/acp
src/main/java/org/attribyte/sql/pool/ConnectionPoolSegment.java
ConnectionPoolSegment.isIdle
final boolean isIdle() { for(ConnectionPoolConnection conn : connections) { if(conn.state.get() == ConnectionPoolConnection.STATE_OPEN) { return false; } } return true; }
java
final boolean isIdle() { for(ConnectionPoolConnection conn : connections) { if(conn.state.get() == ConnectionPoolConnection.STATE_OPEN) { return false; } } return true; }
[ "final", "boolean", "isIdle", "(", ")", "{", "for", "(", "ConnectionPoolConnection", "conn", ":", "connections", ")", "{", "if", "(", "conn", ".", "state", ".", "get", "(", ")", "==", "ConnectionPoolConnection", ".", "STATE_OPEN", ")", "{", "return", "fals...
Determine if this segment is currently idle. @return Is the segment idle?
[ "Determine", "if", "this", "segment", "is", "currently", "idle", "." ]
dbee6ebb83fda4f19fbbbcb9d0ac2b527e3cb659
https://github.com/attribyte/acp/blob/dbee6ebb83fda4f19fbbbcb9d0ac2b527e3cb659/src/main/java/org/attribyte/sql/pool/ConnectionPoolSegment.java#L1239-L1246
train
attribyte/acp
src/main/java/org/attribyte/sql/pool/ConnectionPoolSegment.java
ConnectionPoolSegment.deactivateNow
final void deactivateNow() { isActive = false; stats.deactivate(); availableQueue.clear(); reopenExecutor.getQueue().clear(); for(ConnectionPoolConnection conn : connections) { conn.forceRealClose(); conn.state.set(ConnectionPoolConnection.STATE_DISCONNECTED); } }
java
final void deactivateNow() { isActive = false; stats.deactivate(); availableQueue.clear(); reopenExecutor.getQueue().clear(); for(ConnectionPoolConnection conn : connections) { conn.forceRealClose(); conn.state.set(ConnectionPoolConnection.STATE_DISCONNECTED); } }
[ "final", "void", "deactivateNow", "(", ")", "{", "isActive", "=", "false", ";", "stats", ".", "deactivate", "(", ")", ";", "availableQueue", ".", "clear", "(", ")", ";", "reopenExecutor", ".", "getQueue", "(", ")", ".", "clear", "(", ")", ";", "for", ...
Deactivates the pool immediately - real-closing all connections out from under the logical connections.
[ "Deactivates", "the", "pool", "immediately", "-", "real", "-", "closing", "all", "connections", "out", "from", "under", "the", "logical", "connections", "." ]
dbee6ebb83fda4f19fbbbcb9d0ac2b527e3cb659
https://github.com/attribyte/acp/blob/dbee6ebb83fda4f19fbbbcb9d0ac2b527e3cb659/src/main/java/org/attribyte/sql/pool/ConnectionPoolSegment.java#L1301-L1310
train
attribyte/acp
src/main/java/org/attribyte/sql/pool/ConnectionPoolSegment.java
ConnectionPoolSegment.getActiveConnectionCount
public final int getActiveConnectionCount() { if(!isActive) { return 0; } int count = 0; for(ConnectionPoolConnection conn : connections) { if(conn.state.get() != ConnectionPoolConnection.STATE_AVAILABLE) { count++; } } return count; }
java
public final int getActiveConnectionCount() { if(!isActive) { return 0; } int count = 0; for(ConnectionPoolConnection conn : connections) { if(conn.state.get() != ConnectionPoolConnection.STATE_AVAILABLE) { count++; } } return count; }
[ "public", "final", "int", "getActiveConnectionCount", "(", ")", "{", "if", "(", "!", "isActive", ")", "{", "return", "0", ";", "}", "int", "count", "=", "0", ";", "for", "(", "ConnectionPoolConnection", "conn", ":", "connections", ")", "{", "if", "(", ...
Gets the number of active connections. @return The number of active connections.
[ "Gets", "the", "number", "of", "active", "connections", "." ]
dbee6ebb83fda4f19fbbbcb9d0ac2b527e3cb659
https://github.com/attribyte/acp/blob/dbee6ebb83fda4f19fbbbcb9d0ac2b527e3cb659/src/main/java/org/attribyte/sql/pool/ConnectionPoolSegment.java#L1324-L1338
train
attribyte/acp
src/main/java/org/attribyte/sql/pool/ConnectionPoolSegment.java
ConnectionPoolSegment.logError
void logError(final String message) { if(logger != null) { try { StringBuilder buf = new StringBuilder(name); buf.append(":"); buf.append(message); logger.error(buf.toString()); } catch(Throwable t) { //Ignore - logging should not kill anything } } }
java
void logError(final String message) { if(logger != null) { try { StringBuilder buf = new StringBuilder(name); buf.append(":"); buf.append(message); logger.error(buf.toString()); } catch(Throwable t) { //Ignore - logging should not kill anything } } }
[ "void", "logError", "(", "final", "String", "message", ")", "{", "if", "(", "logger", "!=", "null", ")", "{", "try", "{", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", "name", ")", ";", "buf", ".", "append", "(", "\":\"", ")", ";", "buf",...
Logs an error message. @param message The message.
[ "Logs", "an", "error", "message", "." ]
dbee6ebb83fda4f19fbbbcb9d0ac2b527e3cb659
https://github.com/attribyte/acp/blob/dbee6ebb83fda4f19fbbbcb9d0ac2b527e3cb659/src/main/java/org/attribyte/sql/pool/ConnectionPoolSegment.java#L1464-L1475
train
attribyte/acp
src/main/java/org/attribyte/sql/pool/Util.java
Util.getStack
static final String getStack(final boolean filter) { StringBuilder buf = new StringBuilder(); StackTraceElement[] stack = Thread.currentThread().getStackTrace(); for(int i = 2; i < stack.length; i++) { if(!filter) { buf.append(stack[i].toString()); buf.append(NEW_LINE); } else { String s = stack[i].toString(); if(!s.startsWith("org.attribyte.sql.pool")) { buf.append(s); buf.append(NEW_LINE); } } } return buf.toString(); }
java
static final String getStack(final boolean filter) { StringBuilder buf = new StringBuilder(); StackTraceElement[] stack = Thread.currentThread().getStackTrace(); for(int i = 2; i < stack.length; i++) { if(!filter) { buf.append(stack[i].toString()); buf.append(NEW_LINE); } else { String s = stack[i].toString(); if(!s.startsWith("org.attribyte.sql.pool")) { buf.append(s); buf.append(NEW_LINE); } } } return buf.toString(); }
[ "static", "final", "String", "getStack", "(", "final", "boolean", "filter", ")", "{", "StringBuilder", "buf", "=", "new", "StringBuilder", "(", ")", ";", "StackTraceElement", "[", "]", "stack", "=", "Thread", ".", "currentThread", "(", ")", ".", "getStackTra...
Gets the current stack as a string. @param filter Should calls from the pool be filtered? @return The stack as a string.
[ "Gets", "the", "current", "stack", "as", "a", "string", "." ]
dbee6ebb83fda4f19fbbbcb9d0ac2b527e3cb659
https://github.com/attribyte/acp/blob/dbee6ebb83fda4f19fbbbcb9d0ac2b527e3cb659/src/main/java/org/attribyte/sql/pool/Util.java#L97-L113
train