id int32 0 165k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
36,200 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/Keyspace.java | Keyspace.initCf | public void initCf(UUID cfId, String cfName, boolean loadSSTables)
{
ColumnFamilyStore cfs = columnFamilyStores.get(cfId);
if (cfs == null)
{
// CFS being created for the first time, either on server startup or new CF being added.
// We don't worry about races here; startup is safe, and adding multiple idential CFs
// simultaneously is a "don't do that" scenario.
ColumnFamilyStore oldCfs = columnFamilyStores.putIfAbsent(cfId, ColumnFamilyStore.createColumnFamilyStore(this, cfName, loadSSTables));
// CFS mbean instantiation will error out before we hit this, but in case that changes...
if (oldCfs != null)
throw new IllegalStateException("added multiple mappings for cf id " + cfId);
}
else
{
// re-initializing an existing CF. This will happen if you cleared the schema
// on this node and it's getting repopulated from the rest of the cluster.
assert cfs.name.equals(cfName);
cfs.metadata.reload();
cfs.reload();
}
} | java | public void initCf(UUID cfId, String cfName, boolean loadSSTables)
{
ColumnFamilyStore cfs = columnFamilyStores.get(cfId);
if (cfs == null)
{
// CFS being created for the first time, either on server startup or new CF being added.
// We don't worry about races here; startup is safe, and adding multiple idential CFs
// simultaneously is a "don't do that" scenario.
ColumnFamilyStore oldCfs = columnFamilyStores.putIfAbsent(cfId, ColumnFamilyStore.createColumnFamilyStore(this, cfName, loadSSTables));
// CFS mbean instantiation will error out before we hit this, but in case that changes...
if (oldCfs != null)
throw new IllegalStateException("added multiple mappings for cf id " + cfId);
}
else
{
// re-initializing an existing CF. This will happen if you cleared the schema
// on this node and it's getting repopulated from the rest of the cluster.
assert cfs.name.equals(cfName);
cfs.metadata.reload();
cfs.reload();
}
} | [
"public",
"void",
"initCf",
"(",
"UUID",
"cfId",
",",
"String",
"cfName",
",",
"boolean",
"loadSSTables",
")",
"{",
"ColumnFamilyStore",
"cfs",
"=",
"columnFamilyStores",
".",
"get",
"(",
"cfId",
")",
";",
"if",
"(",
"cfs",
"==",
"null",
")",
"{",
"// CF... | adds a cf to internal structures, ends up creating disk files). | [
"adds",
"a",
"cf",
"to",
"internal",
"structures",
"ends",
"up",
"creating",
"disk",
"files",
")",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/Keyspace.java#L315-L337 |
36,201 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/Keyspace.java | Keyspace.apply | public void apply(Mutation mutation, boolean writeCommitLog, boolean updateIndexes)
{
try (OpOrder.Group opGroup = writeOrder.start())
{
// write the mutation to the commitlog and memtables
ReplayPosition replayPosition = null;
if (writeCommitLog)
{
Tracing.trace("Appending to commitlog");
replayPosition = CommitLog.instance.add(mutation);
}
DecoratedKey key = StorageService.getPartitioner().decorateKey(mutation.key());
for (ColumnFamily cf : mutation.getColumnFamilies())
{
ColumnFamilyStore cfs = columnFamilyStores.get(cf.id());
if (cfs == null)
{
logger.error("Attempting to mutate non-existant column family {}", cf.id());
continue;
}
Tracing.trace("Adding to {} memtable", cf.metadata().cfName);
SecondaryIndexManager.Updater updater = updateIndexes
? cfs.indexManager.updaterFor(key, cf, opGroup)
: SecondaryIndexManager.nullUpdater;
cfs.apply(key, cf, updater, opGroup, replayPosition);
}
}
} | java | public void apply(Mutation mutation, boolean writeCommitLog, boolean updateIndexes)
{
try (OpOrder.Group opGroup = writeOrder.start())
{
// write the mutation to the commitlog and memtables
ReplayPosition replayPosition = null;
if (writeCommitLog)
{
Tracing.trace("Appending to commitlog");
replayPosition = CommitLog.instance.add(mutation);
}
DecoratedKey key = StorageService.getPartitioner().decorateKey(mutation.key());
for (ColumnFamily cf : mutation.getColumnFamilies())
{
ColumnFamilyStore cfs = columnFamilyStores.get(cf.id());
if (cfs == null)
{
logger.error("Attempting to mutate non-existant column family {}", cf.id());
continue;
}
Tracing.trace("Adding to {} memtable", cf.metadata().cfName);
SecondaryIndexManager.Updater updater = updateIndexes
? cfs.indexManager.updaterFor(key, cf, opGroup)
: SecondaryIndexManager.nullUpdater;
cfs.apply(key, cf, updater, opGroup, replayPosition);
}
}
} | [
"public",
"void",
"apply",
"(",
"Mutation",
"mutation",
",",
"boolean",
"writeCommitLog",
",",
"boolean",
"updateIndexes",
")",
"{",
"try",
"(",
"OpOrder",
".",
"Group",
"opGroup",
"=",
"writeOrder",
".",
"start",
"(",
")",
")",
"{",
"// write the mutation to ... | This method appends a row to the global CommitLog, then updates memtables and indexes.
@param mutation the row to write. Must not be modified after calling apply, since commitlog append
may happen concurrently, depending on the CL Executor type.
@param writeCommitLog false to disable commitlog append entirely
@param updateIndexes false to disable index updates (used by CollationController "defragmenting") | [
"This",
"method",
"appends",
"a",
"row",
"to",
"the",
"global",
"CommitLog",
"then",
"updates",
"memtables",
"and",
"indexes",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/Keyspace.java#L359-L388 |
36,202 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/cql3/functions/AbstractFunction.java | AbstractFunction.factory | public static Function.Factory factory(final Function fun)
{
return new Function.Factory()
{
public Function create(String ksName, String cfName)
{
return fun;
}
};
} | java | public static Function.Factory factory(final Function fun)
{
return new Function.Factory()
{
public Function create(String ksName, String cfName)
{
return fun;
}
};
} | [
"public",
"static",
"Function",
".",
"Factory",
"factory",
"(",
"final",
"Function",
"fun",
")",
"{",
"return",
"new",
"Function",
".",
"Factory",
"(",
")",
"{",
"public",
"Function",
"create",
"(",
"String",
"ksName",
",",
"String",
"cfName",
")",
"{",
... | Creates a trivial factory that always return the provided function. | [
"Creates",
"a",
"trivial",
"factory",
"that",
"always",
"return",
"the",
"provided",
"function",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/cql3/functions/AbstractFunction.java#L62-L71 |
36,203 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/thrift/TCustomSocket.java | TCustomSocket.initSocket | private void initSocket() {
socket = new Socket();
try {
socket.setSoLinger(false, 0);
socket.setTcpNoDelay(true);
socket.setSoTimeout(timeout);
} catch (SocketException sx) {
LOGGER.error("Could not configure socket.", sx);
}
} | java | private void initSocket() {
socket = new Socket();
try {
socket.setSoLinger(false, 0);
socket.setTcpNoDelay(true);
socket.setSoTimeout(timeout);
} catch (SocketException sx) {
LOGGER.error("Could not configure socket.", sx);
}
} | [
"private",
"void",
"initSocket",
"(",
")",
"{",
"socket",
"=",
"new",
"Socket",
"(",
")",
";",
"try",
"{",
"socket",
".",
"setSoLinger",
"(",
"false",
",",
"0",
")",
";",
"socket",
".",
"setTcpNoDelay",
"(",
"true",
")",
";",
"socket",
".",
"setSoTim... | Initializes the socket object | [
"Initializes",
"the",
"socket",
"object"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/thrift/TCustomSocket.java#L118-L127 |
36,204 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/thrift/TCustomSocket.java | TCustomSocket.setTimeout | public void setTimeout(int timeout) {
this.timeout = timeout;
try {
socket.setSoTimeout(timeout);
} catch (SocketException sx) {
LOGGER.warn("Could not set socket timeout.", sx);
}
} | java | public void setTimeout(int timeout) {
this.timeout = timeout;
try {
socket.setSoTimeout(timeout);
} catch (SocketException sx) {
LOGGER.warn("Could not set socket timeout.", sx);
}
} | [
"public",
"void",
"setTimeout",
"(",
"int",
"timeout",
")",
"{",
"this",
".",
"timeout",
"=",
"timeout",
";",
"try",
"{",
"socket",
".",
"setSoTimeout",
"(",
"timeout",
")",
";",
"}",
"catch",
"(",
"SocketException",
"sx",
")",
"{",
"LOGGER",
".",
"war... | Sets the socket timeout
@param timeout Milliseconds timeout | [
"Sets",
"the",
"socket",
"timeout"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/thrift/TCustomSocket.java#L134-L141 |
36,205 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/thrift/TCustomSocket.java | TCustomSocket.open | public void open() throws TTransportException {
if (isOpen()) {
throw new TTransportException(TTransportException.ALREADY_OPEN, "Socket already connected.");
}
if (host.length() == 0) {
throw new TTransportException(TTransportException.NOT_OPEN, "Cannot open null host.");
}
if (port <= 0) {
throw new TTransportException(TTransportException.NOT_OPEN, "Cannot open without port.");
}
if (socket == null) {
initSocket();
}
try {
socket.connect(new InetSocketAddress(host, port), timeout);
inputStream_ = new BufferedInputStream(socket.getInputStream(), 1024);
outputStream_ = new BufferedOutputStream(socket.getOutputStream(), 1024);
} catch (IOException iox) {
close();
throw new TTransportException(TTransportException.NOT_OPEN, iox);
}
} | java | public void open() throws TTransportException {
if (isOpen()) {
throw new TTransportException(TTransportException.ALREADY_OPEN, "Socket already connected.");
}
if (host.length() == 0) {
throw new TTransportException(TTransportException.NOT_OPEN, "Cannot open null host.");
}
if (port <= 0) {
throw new TTransportException(TTransportException.NOT_OPEN, "Cannot open without port.");
}
if (socket == null) {
initSocket();
}
try {
socket.connect(new InetSocketAddress(host, port), timeout);
inputStream_ = new BufferedInputStream(socket.getInputStream(), 1024);
outputStream_ = new BufferedOutputStream(socket.getOutputStream(), 1024);
} catch (IOException iox) {
close();
throw new TTransportException(TTransportException.NOT_OPEN, iox);
}
} | [
"public",
"void",
"open",
"(",
")",
"throws",
"TTransportException",
"{",
"if",
"(",
"isOpen",
"(",
")",
")",
"{",
"throw",
"new",
"TTransportException",
"(",
"TTransportException",
".",
"ALREADY_OPEN",
",",
"\"Socket already connected.\"",
")",
";",
"}",
"if",
... | Connects the socket, creating a new socket object if necessary. | [
"Connects",
"the",
"socket",
"creating",
"a",
"new",
"socket",
"object",
"if",
"necessary",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/thrift/TCustomSocket.java#L166-L190 |
36,206 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java | AbstractCompositeType.split | public ByteBuffer[] split(ByteBuffer name)
{
List<ByteBuffer> l = new ArrayList<ByteBuffer>();
ByteBuffer bb = name.duplicate();
readIsStatic(bb);
int i = 0;
while (bb.remaining() > 0)
{
getComparator(i++, bb);
l.add(ByteBufferUtil.readBytesWithShortLength(bb));
bb.get(); // skip end-of-component
}
return l.toArray(new ByteBuffer[l.size()]);
} | java | public ByteBuffer[] split(ByteBuffer name)
{
List<ByteBuffer> l = new ArrayList<ByteBuffer>();
ByteBuffer bb = name.duplicate();
readIsStatic(bb);
int i = 0;
while (bb.remaining() > 0)
{
getComparator(i++, bb);
l.add(ByteBufferUtil.readBytesWithShortLength(bb));
bb.get(); // skip end-of-component
}
return l.toArray(new ByteBuffer[l.size()]);
} | [
"public",
"ByteBuffer",
"[",
"]",
"split",
"(",
"ByteBuffer",
"name",
")",
"{",
"List",
"<",
"ByteBuffer",
">",
"l",
"=",
"new",
"ArrayList",
"<",
"ByteBuffer",
">",
"(",
")",
";",
"ByteBuffer",
"bb",
"=",
"name",
".",
"duplicate",
"(",
")",
";",
"re... | Split a composite column names into it's components. | [
"Split",
"a",
"composite",
"column",
"names",
"into",
"it",
"s",
"components",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/marshal/AbstractCompositeType.java#L90-L103 |
36,207 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/cache/ConcurrentLinkedHashCache.java | ConcurrentLinkedHashCache.create | public static <K extends IMeasurableMemory, V extends IMeasurableMemory> ConcurrentLinkedHashCache<K, V> create(long weightedCapacity, EntryWeigher<K, V> entryWeiger)
{
ConcurrentLinkedHashMap<K, V> map = new ConcurrentLinkedHashMap.Builder<K, V>()
.weigher(entryWeiger)
.maximumWeightedCapacity(weightedCapacity)
.concurrencyLevel(DEFAULT_CONCURENCY_LEVEL)
.build();
return new ConcurrentLinkedHashCache<K, V>(map);
} | java | public static <K extends IMeasurableMemory, V extends IMeasurableMemory> ConcurrentLinkedHashCache<K, V> create(long weightedCapacity, EntryWeigher<K, V> entryWeiger)
{
ConcurrentLinkedHashMap<K, V> map = new ConcurrentLinkedHashMap.Builder<K, V>()
.weigher(entryWeiger)
.maximumWeightedCapacity(weightedCapacity)
.concurrencyLevel(DEFAULT_CONCURENCY_LEVEL)
.build();
return new ConcurrentLinkedHashCache<K, V>(map);
} | [
"public",
"static",
"<",
"K",
"extends",
"IMeasurableMemory",
",",
"V",
"extends",
"IMeasurableMemory",
">",
"ConcurrentLinkedHashCache",
"<",
"K",
",",
"V",
">",
"create",
"(",
"long",
"weightedCapacity",
",",
"EntryWeigher",
"<",
"K",
",",
"V",
">",
"entryWe... | Initialize a cache with initial capacity with weightedCapacity | [
"Initialize",
"a",
"cache",
"with",
"initial",
"capacity",
"with",
"weightedCapacity"
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/cache/ConcurrentLinkedHashCache.java#L40-L49 |
36,208 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/repair/StreamingRepairTask.java | StreamingRepairTask.onSuccess | public void onSuccess(StreamState state)
{
logger.info(String.format("[repair #%s] streaming task succeed, returning response to %s", desc.sessionId, request.initiator));
MessagingService.instance().sendOneWay(new SyncComplete(desc, request.src, request.dst, true).createMessage(), request.initiator);
} | java | public void onSuccess(StreamState state)
{
logger.info(String.format("[repair #%s] streaming task succeed, returning response to %s", desc.sessionId, request.initiator));
MessagingService.instance().sendOneWay(new SyncComplete(desc, request.src, request.dst, true).createMessage(), request.initiator);
} | [
"public",
"void",
"onSuccess",
"(",
"StreamState",
"state",
")",
"{",
"logger",
".",
"info",
"(",
"String",
".",
"format",
"(",
"\"[repair #%s] streaming task succeed, returning response to %s\"",
",",
"desc",
".",
"sessionId",
",",
"request",
".",
"initiator",
")",... | If we succeeded on both stream in and out, reply back to the initiator. | [
"If",
"we",
"succeeded",
"on",
"both",
"stream",
"in",
"and",
"out",
"reply",
"back",
"to",
"the",
"initiator",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/repair/StreamingRepairTask.java#L94-L98 |
36,209 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/repair/StreamingRepairTask.java | StreamingRepairTask.onFailure | public void onFailure(Throwable t)
{
MessagingService.instance().sendOneWay(new SyncComplete(desc, request.src, request.dst, false).createMessage(), request.initiator);
} | java | public void onFailure(Throwable t)
{
MessagingService.instance().sendOneWay(new SyncComplete(desc, request.src, request.dst, false).createMessage(), request.initiator);
} | [
"public",
"void",
"onFailure",
"(",
"Throwable",
"t",
")",
"{",
"MessagingService",
".",
"instance",
"(",
")",
".",
"sendOneWay",
"(",
"new",
"SyncComplete",
"(",
"desc",
",",
"request",
".",
"src",
",",
"request",
".",
"dst",
",",
"false",
")",
".",
"... | If we failed on either stream in or out, reply fail to the initiator. | [
"If",
"we",
"failed",
"on",
"either",
"stream",
"in",
"or",
"out",
"reply",
"fail",
"to",
"the",
"initiator",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/repair/StreamingRepairTask.java#L103-L106 |
36,210 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/context/CounterContext.java | CounterContext.createLocal | public ByteBuffer createLocal(long count)
{
ContextState state = ContextState.allocate(0, 1, 0);
state.writeLocal(CounterId.getLocalId(), 1L, count);
return state.context;
} | java | public ByteBuffer createLocal(long count)
{
ContextState state = ContextState.allocate(0, 1, 0);
state.writeLocal(CounterId.getLocalId(), 1L, count);
return state.context;
} | [
"public",
"ByteBuffer",
"createLocal",
"(",
"long",
"count",
")",
"{",
"ContextState",
"state",
"=",
"ContextState",
".",
"allocate",
"(",
"0",
",",
"1",
",",
"0",
")",
";",
"state",
".",
"writeLocal",
"(",
"CounterId",
".",
"getLocalId",
"(",
")",
",",
... | Creates a counter context with a single local shard.
For use by tests of compatibility with pre-2.1 counters only. | [
"Creates",
"a",
"counter",
"context",
"with",
"a",
"single",
"local",
"shard",
".",
"For",
"use",
"by",
"tests",
"of",
"compatibility",
"with",
"pre",
"-",
"2",
".",
"1",
"counters",
"only",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/context/CounterContext.java#L116-L121 |
36,211 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/context/CounterContext.java | CounterContext.createRemote | public ByteBuffer createRemote(CounterId id, long clock, long count)
{
ContextState state = ContextState.allocate(0, 0, 1);
state.writeRemote(id, clock, count);
return state.context;
} | java | public ByteBuffer createRemote(CounterId id, long clock, long count)
{
ContextState state = ContextState.allocate(0, 0, 1);
state.writeRemote(id, clock, count);
return state.context;
} | [
"public",
"ByteBuffer",
"createRemote",
"(",
"CounterId",
"id",
",",
"long",
"clock",
",",
"long",
"count",
")",
"{",
"ContextState",
"state",
"=",
"ContextState",
".",
"allocate",
"(",
"0",
",",
"0",
",",
"1",
")",
";",
"state",
".",
"writeRemote",
"(",... | Creates a counter context with a single remote shard.
For use by tests of compatibility with pre-2.1 counters only. | [
"Creates",
"a",
"counter",
"context",
"with",
"a",
"single",
"remote",
"shard",
".",
"For",
"use",
"by",
"tests",
"of",
"compatibility",
"with",
"pre",
"-",
"2",
".",
"1",
"counters",
"only",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/context/CounterContext.java#L127-L132 |
36,212 | Stratio/stratio-cassandra | src/java/org/apache/cassandra/db/context/CounterContext.java | CounterContext.diff | public Relationship diff(ByteBuffer left, ByteBuffer right)
{
Relationship relationship = Relationship.EQUAL;
ContextState leftState = ContextState.wrap(left);
ContextState rightState = ContextState.wrap(right);
while (leftState.hasRemaining() && rightState.hasRemaining())
{
// compare id bytes
int compareId = leftState.compareIdTo(rightState);
if (compareId == 0)
{
long leftClock = leftState.getClock();
long rightClock = rightState.getClock();
long leftCount = leftState.getCount();
long rightCount = rightState.getCount();
// advance
leftState.moveToNext();
rightState.moveToNext();
// process clock comparisons
if (leftClock == rightClock)
{
if (leftCount != rightCount)
{
// Inconsistent shard (see the corresponding code in merge()). We return DISJOINT in this
// case so that it will be treated as a difference, allowing read-repair to work.
return Relationship.DISJOINT;
}
}
else if ((leftClock >= 0 && rightClock > 0 && leftClock > rightClock)
|| (leftClock < 0 && (rightClock > 0 || leftClock < rightClock)))
{
if (relationship == Relationship.EQUAL)
relationship = Relationship.GREATER_THAN;
else if (relationship == Relationship.LESS_THAN)
return Relationship.DISJOINT;
// relationship == Relationship.GREATER_THAN
}
else
{
if (relationship == Relationship.EQUAL)
relationship = Relationship.LESS_THAN;
else if (relationship == Relationship.GREATER_THAN)
return Relationship.DISJOINT;
// relationship == Relationship.LESS_THAN
}
}
else if (compareId > 0)
{
// only advance the right context
rightState.moveToNext();
if (relationship == Relationship.EQUAL)
relationship = Relationship.LESS_THAN;
else if (relationship == Relationship.GREATER_THAN)
return Relationship.DISJOINT;
// relationship == Relationship.LESS_THAN
}
else // compareId < 0
{
// only advance the left context
leftState.moveToNext();
if (relationship == Relationship.EQUAL)
relationship = Relationship.GREATER_THAN;
else if (relationship == Relationship.LESS_THAN)
return Relationship.DISJOINT;
// relationship == Relationship.GREATER_THAN
}
}
// check final lengths
if (leftState.hasRemaining())
{
if (relationship == Relationship.EQUAL)
return Relationship.GREATER_THAN;
else if (relationship == Relationship.LESS_THAN)
return Relationship.DISJOINT;
}
if (rightState.hasRemaining())
{
if (relationship == Relationship.EQUAL)
return Relationship.LESS_THAN;
else if (relationship == Relationship.GREATER_THAN)
return Relationship.DISJOINT;
}
return relationship;
} | java | public Relationship diff(ByteBuffer left, ByteBuffer right)
{
Relationship relationship = Relationship.EQUAL;
ContextState leftState = ContextState.wrap(left);
ContextState rightState = ContextState.wrap(right);
while (leftState.hasRemaining() && rightState.hasRemaining())
{
// compare id bytes
int compareId = leftState.compareIdTo(rightState);
if (compareId == 0)
{
long leftClock = leftState.getClock();
long rightClock = rightState.getClock();
long leftCount = leftState.getCount();
long rightCount = rightState.getCount();
// advance
leftState.moveToNext();
rightState.moveToNext();
// process clock comparisons
if (leftClock == rightClock)
{
if (leftCount != rightCount)
{
// Inconsistent shard (see the corresponding code in merge()). We return DISJOINT in this
// case so that it will be treated as a difference, allowing read-repair to work.
return Relationship.DISJOINT;
}
}
else if ((leftClock >= 0 && rightClock > 0 && leftClock > rightClock)
|| (leftClock < 0 && (rightClock > 0 || leftClock < rightClock)))
{
if (relationship == Relationship.EQUAL)
relationship = Relationship.GREATER_THAN;
else if (relationship == Relationship.LESS_THAN)
return Relationship.DISJOINT;
// relationship == Relationship.GREATER_THAN
}
else
{
if (relationship == Relationship.EQUAL)
relationship = Relationship.LESS_THAN;
else if (relationship == Relationship.GREATER_THAN)
return Relationship.DISJOINT;
// relationship == Relationship.LESS_THAN
}
}
else if (compareId > 0)
{
// only advance the right context
rightState.moveToNext();
if (relationship == Relationship.EQUAL)
relationship = Relationship.LESS_THAN;
else if (relationship == Relationship.GREATER_THAN)
return Relationship.DISJOINT;
// relationship == Relationship.LESS_THAN
}
else // compareId < 0
{
// only advance the left context
leftState.moveToNext();
if (relationship == Relationship.EQUAL)
relationship = Relationship.GREATER_THAN;
else if (relationship == Relationship.LESS_THAN)
return Relationship.DISJOINT;
// relationship == Relationship.GREATER_THAN
}
}
// check final lengths
if (leftState.hasRemaining())
{
if (relationship == Relationship.EQUAL)
return Relationship.GREATER_THAN;
else if (relationship == Relationship.LESS_THAN)
return Relationship.DISJOINT;
}
if (rightState.hasRemaining())
{
if (relationship == Relationship.EQUAL)
return Relationship.LESS_THAN;
else if (relationship == Relationship.GREATER_THAN)
return Relationship.DISJOINT;
}
return relationship;
} | [
"public",
"Relationship",
"diff",
"(",
"ByteBuffer",
"left",
",",
"ByteBuffer",
"right",
")",
"{",
"Relationship",
"relationship",
"=",
"Relationship",
".",
"EQUAL",
";",
"ContextState",
"leftState",
"=",
"ContextState",
".",
"wrap",
"(",
"left",
")",
";",
"Co... | Determine the count relationship between two contexts.
EQUAL: Equal set of nodes and every count is equal.
GREATER_THAN: Superset of nodes and every count is equal or greater than its corollary.
LESS_THAN: Subset of nodes and every count is equal or less than its corollary.
DISJOINT: Node sets are not equal and/or counts are not all greater or less than.
Strategy: compare node logical clocks (like a version vector).
@param left counter context.
@param right counter context.
@return the Relationship between the contexts. | [
"Determine",
"the",
"count",
"relationship",
"between",
"two",
"contexts",
"."
] | f6416b43ad5309083349ad56266450fa8c6a2106 | https://github.com/Stratio/stratio-cassandra/blob/f6416b43ad5309083349ad56266450fa8c6a2106/src/java/org/apache/cassandra/db/context/CounterContext.java#L158-L249 |
36,213 | 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 |
36,214 | 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 |
36,215 | 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 |
36,216 | 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 |
36,217 | 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 |
36,218 | 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 |
36,219 | 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 |
36,220 | 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 |
36,221 | 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 |
36,222 | 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 |
36,223 | 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 |
36,224 | 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 |
36,225 | 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 |
36,226 | 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 |
36,227 | 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 |
36,228 | 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 |
36,229 | 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 |
36,230 | 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 |
36,231 | 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 |
36,232 | 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 |
36,233 | 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 |
36,234 | 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 |
36,235 | 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 |
36,236 | 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 |
36,237 | 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 |
36,238 | 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 |
36,239 | 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 |
36,240 | 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 |
36,241 | 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 |
36,242 | 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 |
36,243 | 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 |
36,244 | 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 |
36,245 | 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 |
36,246 | 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 |
36,247 | 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 |
36,248 | 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 |
36,249 | 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 |
36,250 | 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 |
36,251 | 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 |
36,252 | 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 |
36,253 | 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 |
36,254 | 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 |
36,255 | 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 |
36,256 | 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 |
36,257 | 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 |
36,258 | 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 |
36,259 | 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 |
36,260 | 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 |
36,261 | 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 |
36,262 | 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 |
36,263 | 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 |
36,264 | 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 |
36,265 | 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 |
36,266 | 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 |
36,267 | 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 |
36,268 | 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 |
36,269 | 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 |
36,270 | 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 |
36,271 | 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 |
36,272 | 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 |
36,273 | 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 |
36,274 | 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 |
36,275 | 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 |
36,276 | 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 |
36,277 | 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 |
36,278 | 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 |
36,279 | 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 |
36,280 | 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 |
36,281 | 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 |
36,282 | 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 |
36,283 | 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 |
36,284 | 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 |
36,285 | 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 |
36,286 | 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 |
36,287 | 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 |
36,288 | 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 |
36,289 | 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 |
36,290 | 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 |
36,291 | 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 |
36,292 | 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 |
36,293 | 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 |
36,294 | 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 |
36,295 | 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 |
36,296 | 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 |
36,297 | 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 |
36,298 | 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 |
36,299 | 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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.