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
138,000
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/libs/modules/FlowNode.java
FlowNode.getFlowAt
public int getFlowAt( Direction direction ) { switch( direction ) { case E: return eFlow; case W: return wFlow; case N: return nFlow; case S: return sFlow; case EN: return enFlow; case NW: return nwFlow; case WS: return wsFlow; case SE: return seFlow; default: throw new IllegalArgumentException(); } }
java
public int getFlowAt( Direction direction ) { switch( direction ) { case E: return eFlow; case W: return wFlow; case N: return nFlow; case S: return sFlow; case EN: return enFlow; case NW: return nwFlow; case WS: return wsFlow; case SE: return seFlow; default: throw new IllegalArgumentException(); } }
[ "public", "int", "getFlowAt", "(", "Direction", "direction", ")", "{", "switch", "(", "direction", ")", "{", "case", "E", ":", "return", "eFlow", ";", "case", "W", ":", "return", "wFlow", ";", "case", "N", ":", "return", "nFlow", ";", "case", "S", ":", "return", "sFlow", ";", "case", "EN", ":", "return", "enFlow", ";", "case", "NW", ":", "return", "nwFlow", ";", "case", "WS", ":", "return", "wsFlow", ";", "case", "SE", ":", "return", "seFlow", ";", "default", ":", "throw", "new", "IllegalArgumentException", "(", ")", ";", "}", "}" ]
Get the value of the flow in one of the surrounding direction. @param direction the {@link Direction}. @return the flow value.
[ "Get", "the", "value", "of", "the", "flow", "in", "one", "of", "the", "surrounding", "direction", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/libs/modules/FlowNode.java#L205-L226
138,001
TheHortonMachine/hortonmachine
gears/src/main/java/org/hortonmachine/gears/libs/modules/FlowNode.java
FlowNode.goDownstream
public FlowNode goDownstream() { if (isValid) { Direction direction = Direction.forFlow(flow); if (direction != null) { FlowNode nextNode = new FlowNode(gridIter, cols, rows, col + direction.col, row + direction.row); if (nextNode.isValid) { return nextNode; } } } return null; }
java
public FlowNode goDownstream() { if (isValid) { Direction direction = Direction.forFlow(flow); if (direction != null) { FlowNode nextNode = new FlowNode(gridIter, cols, rows, col + direction.col, row + direction.row); if (nextNode.isValid) { return nextNode; } } } return null; }
[ "public", "FlowNode", "goDownstream", "(", ")", "{", "if", "(", "isValid", ")", "{", "Direction", "direction", "=", "Direction", ".", "forFlow", "(", "flow", ")", ";", "if", "(", "direction", "!=", "null", ")", "{", "FlowNode", "nextNode", "=", "new", "FlowNode", "(", "gridIter", ",", "cols", ",", "rows", ",", "col", "+", "direction", ".", "col", ",", "row", "+", "direction", ".", "row", ")", ";", "if", "(", "nextNode", ".", "isValid", ")", "{", "return", "nextNode", ";", "}", "}", "}", "return", "null", ";", "}" ]
Get the next downstream node. @return the next downstream node or <code>null</code> if the end has been reached.
[ "Get", "the", "next", "downstream", "node", "." ]
d2b436bbdf951dc1fda56096a42dbc0eae4d35a5
https://github.com/TheHortonMachine/hortonmachine/blob/d2b436bbdf951dc1fda56096a42dbc0eae4d35a5/gears/src/main/java/org/hortonmachine/gears/libs/modules/FlowNode.java#L233-L244
138,002
moleculer-java/moleculer-java
src/main/java/services/moleculer/context/DefaultContextFactory.java
DefaultContextFactory.started
@Override public void started(ServiceBroker broker) throws Exception { super.started(broker); // Set components ServiceBrokerConfig cfg = broker.getConfig(); serviceInvoker = cfg.getServiceInvoker(); eventbus = cfg.getEventbus(); uid = cfg.getUidGenerator(); }
java
@Override public void started(ServiceBroker broker) throws Exception { super.started(broker); // Set components ServiceBrokerConfig cfg = broker.getConfig(); serviceInvoker = cfg.getServiceInvoker(); eventbus = cfg.getEventbus(); uid = cfg.getUidGenerator(); }
[ "@", "Override", "public", "void", "started", "(", "ServiceBroker", "broker", ")", "throws", "Exception", "{", "super", ".", "started", "(", "broker", ")", ";", "// Set components\r", "ServiceBrokerConfig", "cfg", "=", "broker", ".", "getConfig", "(", ")", ";", "serviceInvoker", "=", "cfg", ".", "getServiceInvoker", "(", ")", ";", "eventbus", "=", "cfg", ".", "getEventbus", "(", ")", ";", "uid", "=", "cfg", ".", "getUidGenerator", "(", ")", ";", "}" ]
Initializes Default Context Factory instance. @param broker parent ServiceBroker
[ "Initializes", "Default", "Context", "Factory", "instance", "." ]
27575c44b9ecacc17c4456ceacf5d1851abf1cc4
https://github.com/moleculer-java/moleculer-java/blob/27575c44b9ecacc17c4456ceacf5d1851abf1cc4/src/main/java/services/moleculer/context/DefaultContextFactory.java#L65-L74
138,003
moleculer-java/moleculer-java
src/main/java/services/moleculer/eventbus/DefaultEventbus.java
DefaultEventbus.started
@Override public void started(ServiceBroker broker) throws Exception { super.started(broker); // Set nodeID this.nodeID = broker.getNodeID(); // Set components ServiceBrokerConfig cfg = broker.getConfig(); this.strategy = cfg.getStrategyFactory(); this.transporter = cfg.getTransporter(); this.executor = cfg.getExecutor(); }
java
@Override public void started(ServiceBroker broker) throws Exception { super.started(broker); // Set nodeID this.nodeID = broker.getNodeID(); // Set components ServiceBrokerConfig cfg = broker.getConfig(); this.strategy = cfg.getStrategyFactory(); this.transporter = cfg.getTransporter(); this.executor = cfg.getExecutor(); }
[ "@", "Override", "public", "void", "started", "(", "ServiceBroker", "broker", ")", "throws", "Exception", "{", "super", ".", "started", "(", "broker", ")", ";", "// Set nodeID", "this", ".", "nodeID", "=", "broker", ".", "getNodeID", "(", ")", ";", "// Set components", "ServiceBrokerConfig", "cfg", "=", "broker", ".", "getConfig", "(", ")", ";", "this", ".", "strategy", "=", "cfg", ".", "getStrategyFactory", "(", ")", ";", "this", ".", "transporter", "=", "cfg", ".", "getTransporter", "(", ")", ";", "this", ".", "executor", "=", "cfg", ".", "getExecutor", "(", ")", ";", "}" ]
Initializes default EventBus instance. @param broker parent ServiceBroker
[ "Initializes", "default", "EventBus", "instance", "." ]
27575c44b9ecacc17c4456ceacf5d1851abf1cc4
https://github.com/moleculer-java/moleculer-java/blob/27575c44b9ecacc17c4456ceacf5d1851abf1cc4/src/main/java/services/moleculer/eventbus/DefaultEventbus.java#L130-L142
138,004
moleculer-java/moleculer-java
src/main/java/services/moleculer/transporter/tcp/SendBuffer.java
SendBuffer.append
protected boolean append(byte[] packet) { ByteBuffer buffer = ByteBuffer.wrap(packet); ByteBuffer blocker; while (true) { blocker = blockerBuffer.get(); if (blocker == BUFFER_IS_CLOSED) { return false; } if (blockerBuffer.compareAndSet(blocker, buffer)) { queue.add(buffer); return true; } } }
java
protected boolean append(byte[] packet) { ByteBuffer buffer = ByteBuffer.wrap(packet); ByteBuffer blocker; while (true) { blocker = blockerBuffer.get(); if (blocker == BUFFER_IS_CLOSED) { return false; } if (blockerBuffer.compareAndSet(blocker, buffer)) { queue.add(buffer); return true; } } }
[ "protected", "boolean", "append", "(", "byte", "[", "]", "packet", ")", "{", "ByteBuffer", "buffer", "=", "ByteBuffer", ".", "wrap", "(", "packet", ")", ";", "ByteBuffer", "blocker", ";", "while", "(", "true", ")", "{", "blocker", "=", "blockerBuffer", ".", "get", "(", ")", ";", "if", "(", "blocker", "==", "BUFFER_IS_CLOSED", ")", "{", "return", "false", ";", "}", "if", "(", "blockerBuffer", ".", "compareAndSet", "(", "blocker", ",", "buffer", ")", ")", "{", "queue", ".", "add", "(", "buffer", ")", ";", "return", "true", ";", "}", "}", "}" ]
Adds a packet to the buffer's queue. @param packet packet to write @return true, if success (false = buffer is closed)
[ "Adds", "a", "packet", "to", "the", "buffer", "s", "queue", "." ]
27575c44b9ecacc17c4456ceacf5d1851abf1cc4
https://github.com/moleculer-java/moleculer-java/blob/27575c44b9ecacc17c4456ceacf5d1851abf1cc4/src/main/java/services/moleculer/transporter/tcp/SendBuffer.java#L101-L114
138,005
moleculer-java/moleculer-java
src/main/java/services/moleculer/transporter/tcp/SendBuffer.java
SendBuffer.tryToClose
protected boolean tryToClose() { ByteBuffer blocker = blockerBuffer.get(); if (blocker == BUFFER_IS_CLOSED) { return true; } if (blocker != null) { return false; } boolean closed = blockerBuffer.compareAndSet(null, BUFFER_IS_CLOSED); if (closed) { closeResources(); return true; } return false; }
java
protected boolean tryToClose() { ByteBuffer blocker = blockerBuffer.get(); if (blocker == BUFFER_IS_CLOSED) { return true; } if (blocker != null) { return false; } boolean closed = blockerBuffer.compareAndSet(null, BUFFER_IS_CLOSED); if (closed) { closeResources(); return true; } return false; }
[ "protected", "boolean", "tryToClose", "(", ")", "{", "ByteBuffer", "blocker", "=", "blockerBuffer", ".", "get", "(", ")", ";", "if", "(", "blocker", "==", "BUFFER_IS_CLOSED", ")", "{", "return", "true", ";", "}", "if", "(", "blocker", "!=", "null", ")", "{", "return", "false", ";", "}", "boolean", "closed", "=", "blockerBuffer", ".", "compareAndSet", "(", "null", ",", "BUFFER_IS_CLOSED", ")", ";", "if", "(", "closed", ")", "{", "closeResources", "(", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Tries to close this buffer. @return true, is closed (false = buffer is not empty)
[ "Tries", "to", "close", "this", "buffer", "." ]
27575c44b9ecacc17c4456ceacf5d1851abf1cc4
https://github.com/moleculer-java/moleculer-java/blob/27575c44b9ecacc17c4456ceacf5d1851abf1cc4/src/main/java/services/moleculer/transporter/tcp/SendBuffer.java#L123-L137
138,006
moleculer-java/moleculer-java
src/main/java/services/moleculer/transporter/tcp/SendBuffer.java
SendBuffer.write
protected void write() throws Exception { ByteBuffer buffer = queue.peek(); if (buffer == null) { if (key != null) { key.interestOps(0); } return; } if (channel != null) { int count; while (true) { count = channel.write(buffer); // Debug if (debug) { logger.info(count + " bytes submitted to " + channel.getRemoteAddress() + "."); } // EOF? if (count == -1) { throw new InvalidPacketDataError(nodeID, "host", host, "port", port); } // Remove the submitted buffer from the queue if (!buffer.hasRemaining()) { queue.poll(); } // Turn off write mode (if the queue is empty) if (queue.isEmpty()) { if (blockerBuffer.compareAndSet(buffer, null) && key != null) { key.interestOps(0); } return; } else { buffer = queue.peek(); } } } }
java
protected void write() throws Exception { ByteBuffer buffer = queue.peek(); if (buffer == null) { if (key != null) { key.interestOps(0); } return; } if (channel != null) { int count; while (true) { count = channel.write(buffer); // Debug if (debug) { logger.info(count + " bytes submitted to " + channel.getRemoteAddress() + "."); } // EOF? if (count == -1) { throw new InvalidPacketDataError(nodeID, "host", host, "port", port); } // Remove the submitted buffer from the queue if (!buffer.hasRemaining()) { queue.poll(); } // Turn off write mode (if the queue is empty) if (queue.isEmpty()) { if (blockerBuffer.compareAndSet(buffer, null) && key != null) { key.interestOps(0); } return; } else { buffer = queue.peek(); } } } }
[ "protected", "void", "write", "(", ")", "throws", "Exception", "{", "ByteBuffer", "buffer", "=", "queue", ".", "peek", "(", ")", ";", "if", "(", "buffer", "==", "null", ")", "{", "if", "(", "key", "!=", "null", ")", "{", "key", ".", "interestOps", "(", "0", ")", ";", "}", "return", ";", "}", "if", "(", "channel", "!=", "null", ")", "{", "int", "count", ";", "while", "(", "true", ")", "{", "count", "=", "channel", ".", "write", "(", "buffer", ")", ";", "// Debug\r", "if", "(", "debug", ")", "{", "logger", ".", "info", "(", "count", "+", "\" bytes submitted to \"", "+", "channel", ".", "getRemoteAddress", "(", ")", "+", "\".\"", ")", ";", "}", "// EOF?\r", "if", "(", "count", "==", "-", "1", ")", "{", "throw", "new", "InvalidPacketDataError", "(", "nodeID", ",", "\"host\"", ",", "host", ",", "\"port\"", ",", "port", ")", ";", "}", "// Remove the submitted buffer from the queue\r", "if", "(", "!", "buffer", ".", "hasRemaining", "(", ")", ")", "{", "queue", ".", "poll", "(", ")", ";", "}", "// Turn off write mode (if the queue is empty)\r", "if", "(", "queue", ".", "isEmpty", "(", ")", ")", "{", "if", "(", "blockerBuffer", ".", "compareAndSet", "(", "buffer", ",", "null", ")", "&&", "key", "!=", "null", ")", "{", "key", ".", "interestOps", "(", "0", ")", ";", "}", "return", ";", "}", "else", "{", "buffer", "=", "queue", ".", "peek", "(", ")", ";", "}", "}", "}", "}" ]
Writes N bytes to the target channel. @throws Exception any I/O exception
[ "Writes", "N", "bytes", "to", "the", "target", "channel", "." ]
27575c44b9ecacc17c4456ceacf5d1851abf1cc4
https://github.com/moleculer-java/moleculer-java/blob/27575c44b9ecacc17c4456ceacf5d1851abf1cc4/src/main/java/services/moleculer/transporter/tcp/SendBuffer.java#L182-L221
138,007
moleculer-java/moleculer-java
src/main/java/services/moleculer/transporter/Transporter.java
Transporter.started
@Override public void started(ServiceBroker broker) throws Exception { super.started(broker); // Process config ServiceBrokerConfig cfg = broker.getConfig(); namespace = cfg.getNamespace(); if (namespace != null && !namespace.isEmpty()) { prefix = prefix + '-' + namespace; } nodeID = broker.getNodeID(); // Log serializer info serializer.started(broker); logger.info(nameOf(this, true) + " will use " + nameOf(serializer, true) + '.'); // Get components executor = cfg.getExecutor(); scheduler = cfg.getScheduler(); registry = cfg.getServiceRegistry(); monitor = cfg.getMonitor(); eventbus = cfg.getEventbus(); uid = cfg.getUidGenerator(); // Set channel names eventChannel = channel(PACKET_EVENT, nodeID); requestChannel = channel(PACKET_REQUEST, nodeID); responseChannel = channel(PACKET_RESPONSE, nodeID); discoverBroadcastChannel = channel(PACKET_DISCOVER, null); discoverChannel = channel(PACKET_DISCOVER, nodeID); infoBroadcastChannel = channel(PACKET_INFO, null); infoChannel = channel(PACKET_INFO, nodeID); disconnectChannel = channel(PACKET_DISCONNECT, null); heartbeatChannel = channel(PACKET_HEARTBEAT, null); pingChannel = channel(PACKET_PING, nodeID); pongChannel = channel(PACKET_PONG, nodeID); }
java
@Override public void started(ServiceBroker broker) throws Exception { super.started(broker); // Process config ServiceBrokerConfig cfg = broker.getConfig(); namespace = cfg.getNamespace(); if (namespace != null && !namespace.isEmpty()) { prefix = prefix + '-' + namespace; } nodeID = broker.getNodeID(); // Log serializer info serializer.started(broker); logger.info(nameOf(this, true) + " will use " + nameOf(serializer, true) + '.'); // Get components executor = cfg.getExecutor(); scheduler = cfg.getScheduler(); registry = cfg.getServiceRegistry(); monitor = cfg.getMonitor(); eventbus = cfg.getEventbus(); uid = cfg.getUidGenerator(); // Set channel names eventChannel = channel(PACKET_EVENT, nodeID); requestChannel = channel(PACKET_REQUEST, nodeID); responseChannel = channel(PACKET_RESPONSE, nodeID); discoverBroadcastChannel = channel(PACKET_DISCOVER, null); discoverChannel = channel(PACKET_DISCOVER, nodeID); infoBroadcastChannel = channel(PACKET_INFO, null); infoChannel = channel(PACKET_INFO, nodeID); disconnectChannel = channel(PACKET_DISCONNECT, null); heartbeatChannel = channel(PACKET_HEARTBEAT, null); pingChannel = channel(PACKET_PING, nodeID); pongChannel = channel(PACKET_PONG, nodeID); }
[ "@", "Override", "public", "void", "started", "(", "ServiceBroker", "broker", ")", "throws", "Exception", "{", "super", ".", "started", "(", "broker", ")", ";", "// Process config\r", "ServiceBrokerConfig", "cfg", "=", "broker", ".", "getConfig", "(", ")", ";", "namespace", "=", "cfg", ".", "getNamespace", "(", ")", ";", "if", "(", "namespace", "!=", "null", "&&", "!", "namespace", ".", "isEmpty", "(", ")", ")", "{", "prefix", "=", "prefix", "+", "'", "'", "+", "namespace", ";", "}", "nodeID", "=", "broker", ".", "getNodeID", "(", ")", ";", "// Log serializer info\r", "serializer", ".", "started", "(", "broker", ")", ";", "logger", ".", "info", "(", "nameOf", "(", "this", ",", "true", ")", "+", "\" will use \"", "+", "nameOf", "(", "serializer", ",", "true", ")", "+", "'", "'", ")", ";", "// Get components\r", "executor", "=", "cfg", ".", "getExecutor", "(", ")", ";", "scheduler", "=", "cfg", ".", "getScheduler", "(", ")", ";", "registry", "=", "cfg", ".", "getServiceRegistry", "(", ")", ";", "monitor", "=", "cfg", ".", "getMonitor", "(", ")", ";", "eventbus", "=", "cfg", ".", "getEventbus", "(", ")", ";", "uid", "=", "cfg", ".", "getUidGenerator", "(", ")", ";", "// Set channel names\r", "eventChannel", "=", "channel", "(", "PACKET_EVENT", ",", "nodeID", ")", ";", "requestChannel", "=", "channel", "(", "PACKET_REQUEST", ",", "nodeID", ")", ";", "responseChannel", "=", "channel", "(", "PACKET_RESPONSE", ",", "nodeID", ")", ";", "discoverBroadcastChannel", "=", "channel", "(", "PACKET_DISCOVER", ",", "null", ")", ";", "discoverChannel", "=", "channel", "(", "PACKET_DISCOVER", ",", "nodeID", ")", ";", "infoBroadcastChannel", "=", "channel", "(", "PACKET_INFO", ",", "null", ")", ";", "infoChannel", "=", "channel", "(", "PACKET_INFO", ",", "nodeID", ")", ";", "disconnectChannel", "=", "channel", "(", "PACKET_DISCONNECT", ",", "null", ")", ";", "heartbeatChannel", "=", "channel", "(", "PACKET_HEARTBEAT", ",", "null", ")", ";", "pingChannel", "=", "channel", "(", "PACKET_PING", ",", "nodeID", ")", ";", "pongChannel", "=", "channel", "(", "PACKET_PONG", ",", "nodeID", ")", ";", "}" ]
Initializes transporter instance. @param broker parent ServiceBroker
[ "Initializes", "transporter", "instance", "." ]
27575c44b9ecacc17c4456ceacf5d1851abf1cc4
https://github.com/moleculer-java/moleculer-java/blob/27575c44b9ecacc17c4456ceacf5d1851abf1cc4/src/main/java/services/moleculer/transporter/Transporter.java#L200-L236
138,008
moleculer-java/moleculer-java
src/main/java/services/moleculer/service/DefaultServiceRegistry.java
DefaultServiceRegistry.started
@Override public void started(ServiceBroker broker) throws Exception { super.started(broker); // Local nodeID this.nodeID = broker.getNodeID(); // Set components ServiceBrokerConfig cfg = broker.getConfig(); this.executor = cfg.getExecutor(); this.scheduler = cfg.getScheduler(); this.strategyFactory = cfg.getStrategyFactory(); this.contextFactory = cfg.getContextFactory(); this.transporter = cfg.getTransporter(); this.eventbus = cfg.getEventbus(); this.uid = cfg.getUidGenerator(); }
java
@Override public void started(ServiceBroker broker) throws Exception { super.started(broker); // Local nodeID this.nodeID = broker.getNodeID(); // Set components ServiceBrokerConfig cfg = broker.getConfig(); this.executor = cfg.getExecutor(); this.scheduler = cfg.getScheduler(); this.strategyFactory = cfg.getStrategyFactory(); this.contextFactory = cfg.getContextFactory(); this.transporter = cfg.getTransporter(); this.eventbus = cfg.getEventbus(); this.uid = cfg.getUidGenerator(); }
[ "@", "Override", "public", "void", "started", "(", "ServiceBroker", "broker", ")", "throws", "Exception", "{", "super", ".", "started", "(", "broker", ")", ";", "// Local nodeID", "this", ".", "nodeID", "=", "broker", ".", "getNodeID", "(", ")", ";", "// Set components", "ServiceBrokerConfig", "cfg", "=", "broker", ".", "getConfig", "(", ")", ";", "this", ".", "executor", "=", "cfg", ".", "getExecutor", "(", ")", ";", "this", ".", "scheduler", "=", "cfg", ".", "getScheduler", "(", ")", ";", "this", ".", "strategyFactory", "=", "cfg", ".", "getStrategyFactory", "(", ")", ";", "this", ".", "contextFactory", "=", "cfg", ".", "getContextFactory", "(", ")", ";", "this", ".", "transporter", "=", "cfg", ".", "getTransporter", "(", ")", ";", "this", ".", "eventbus", "=", "cfg", ".", "getEventbus", "(", ")", ";", "this", ".", "uid", "=", "cfg", ".", "getUidGenerator", "(", ")", ";", "}" ]
Initializes ServiceRegistry instance. @param broker parent ServiceBroker
[ "Initializes", "ServiceRegistry", "instance", "." ]
27575c44b9ecacc17c4456ceacf5d1851abf1cc4
https://github.com/moleculer-java/moleculer-java/blob/27575c44b9ecacc17c4456ceacf5d1851abf1cc4/src/main/java/services/moleculer/service/DefaultServiceRegistry.java#L235-L251
138,009
moleculer-java/moleculer-java
src/main/java/services/moleculer/service/DefaultServiceRegistry.java
DefaultServiceRegistry.reschedule
protected void reschedule(long minTimeoutAt) { if (minTimeoutAt == Long.MAX_VALUE) { for (PendingPromise pending : promises.values()) { if (pending.timeoutAt > 0 && pending.timeoutAt < minTimeoutAt) { minTimeoutAt = pending.timeoutAt; } } long timeoutAt; requestStreamReadLock.lock(); try { for (IncomingStream stream : requestStreams.values()) { timeoutAt = stream.getTimeoutAt(); if (timeoutAt > 0 && timeoutAt < minTimeoutAt) { minTimeoutAt = timeoutAt; } } } finally { requestStreamReadLock.unlock(); } responseStreamReadLock.lock(); try { for (IncomingStream stream : responseStreams.values()) { timeoutAt = stream.getTimeoutAt(); if (timeoutAt > 0 && timeoutAt < minTimeoutAt) { minTimeoutAt = timeoutAt; } } } finally { responseStreamReadLock.unlock(); } } long now = System.currentTimeMillis(); if (minTimeoutAt == Long.MAX_VALUE) { ScheduledFuture<?> t = callTimeoutTimer.get(); if (t != null) { if (prevTimeoutAt.get() > now) { t.cancel(false); prevTimeoutAt.set(0); } else { callTimeoutTimer.set(null); prevTimeoutAt.set(0); } } } else { minTimeoutAt = (minTimeoutAt / 100 * 100) + 100; long prev = prevTimeoutAt.getAndSet(minTimeoutAt); if (prev == minTimeoutAt) { // Next when not changed return; } // Stop previous timer ScheduledFuture<?> t = callTimeoutTimer.get(); if (t != null) { t.cancel(false); } // Schedule next timeout timer long delay = Math.max(10, minTimeoutAt - now); callTimeoutTimer.set(scheduler.schedule(this::checkTimeouts, delay, TimeUnit.MILLISECONDS)); } }
java
protected void reschedule(long minTimeoutAt) { if (minTimeoutAt == Long.MAX_VALUE) { for (PendingPromise pending : promises.values()) { if (pending.timeoutAt > 0 && pending.timeoutAt < minTimeoutAt) { minTimeoutAt = pending.timeoutAt; } } long timeoutAt; requestStreamReadLock.lock(); try { for (IncomingStream stream : requestStreams.values()) { timeoutAt = stream.getTimeoutAt(); if (timeoutAt > 0 && timeoutAt < minTimeoutAt) { minTimeoutAt = timeoutAt; } } } finally { requestStreamReadLock.unlock(); } responseStreamReadLock.lock(); try { for (IncomingStream stream : responseStreams.values()) { timeoutAt = stream.getTimeoutAt(); if (timeoutAt > 0 && timeoutAt < minTimeoutAt) { minTimeoutAt = timeoutAt; } } } finally { responseStreamReadLock.unlock(); } } long now = System.currentTimeMillis(); if (minTimeoutAt == Long.MAX_VALUE) { ScheduledFuture<?> t = callTimeoutTimer.get(); if (t != null) { if (prevTimeoutAt.get() > now) { t.cancel(false); prevTimeoutAt.set(0); } else { callTimeoutTimer.set(null); prevTimeoutAt.set(0); } } } else { minTimeoutAt = (minTimeoutAt / 100 * 100) + 100; long prev = prevTimeoutAt.getAndSet(minTimeoutAt); if (prev == minTimeoutAt) { // Next when not changed return; } // Stop previous timer ScheduledFuture<?> t = callTimeoutTimer.get(); if (t != null) { t.cancel(false); } // Schedule next timeout timer long delay = Math.max(10, minTimeoutAt - now); callTimeoutTimer.set(scheduler.schedule(this::checkTimeouts, delay, TimeUnit.MILLISECONDS)); } }
[ "protected", "void", "reschedule", "(", "long", "minTimeoutAt", ")", "{", "if", "(", "minTimeoutAt", "==", "Long", ".", "MAX_VALUE", ")", "{", "for", "(", "PendingPromise", "pending", ":", "promises", ".", "values", "(", ")", ")", "{", "if", "(", "pending", ".", "timeoutAt", ">", "0", "&&", "pending", ".", "timeoutAt", "<", "minTimeoutAt", ")", "{", "minTimeoutAt", "=", "pending", ".", "timeoutAt", ";", "}", "}", "long", "timeoutAt", ";", "requestStreamReadLock", ".", "lock", "(", ")", ";", "try", "{", "for", "(", "IncomingStream", "stream", ":", "requestStreams", ".", "values", "(", ")", ")", "{", "timeoutAt", "=", "stream", ".", "getTimeoutAt", "(", ")", ";", "if", "(", "timeoutAt", ">", "0", "&&", "timeoutAt", "<", "minTimeoutAt", ")", "{", "minTimeoutAt", "=", "timeoutAt", ";", "}", "}", "}", "finally", "{", "requestStreamReadLock", ".", "unlock", "(", ")", ";", "}", "responseStreamReadLock", ".", "lock", "(", ")", ";", "try", "{", "for", "(", "IncomingStream", "stream", ":", "responseStreams", ".", "values", "(", ")", ")", "{", "timeoutAt", "=", "stream", ".", "getTimeoutAt", "(", ")", ";", "if", "(", "timeoutAt", ">", "0", "&&", "timeoutAt", "<", "minTimeoutAt", ")", "{", "minTimeoutAt", "=", "timeoutAt", ";", "}", "}", "}", "finally", "{", "responseStreamReadLock", ".", "unlock", "(", ")", ";", "}", "}", "long", "now", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "if", "(", "minTimeoutAt", "==", "Long", ".", "MAX_VALUE", ")", "{", "ScheduledFuture", "<", "?", ">", "t", "=", "callTimeoutTimer", ".", "get", "(", ")", ";", "if", "(", "t", "!=", "null", ")", "{", "if", "(", "prevTimeoutAt", ".", "get", "(", ")", ">", "now", ")", "{", "t", ".", "cancel", "(", "false", ")", ";", "prevTimeoutAt", ".", "set", "(", "0", ")", ";", "}", "else", "{", "callTimeoutTimer", ".", "set", "(", "null", ")", ";", "prevTimeoutAt", ".", "set", "(", "0", ")", ";", "}", "}", "}", "else", "{", "minTimeoutAt", "=", "(", "minTimeoutAt", "/", "100", "*", "100", ")", "+", "100", ";", "long", "prev", "=", "prevTimeoutAt", ".", "getAndSet", "(", "minTimeoutAt", ")", ";", "if", "(", "prev", "==", "minTimeoutAt", ")", "{", "// Next when not changed", "return", ";", "}", "// Stop previous timer", "ScheduledFuture", "<", "?", ">", "t", "=", "callTimeoutTimer", ".", "get", "(", ")", ";", "if", "(", "t", "!=", "null", ")", "{", "t", ".", "cancel", "(", "false", ")", ";", "}", "// Schedule next timeout timer", "long", "delay", "=", "Math", ".", "max", "(", "10", ",", "minTimeoutAt", "-", "now", ")", ";", "callTimeoutTimer", ".", "set", "(", "scheduler", ".", "schedule", "(", "this", "::", "checkTimeouts", ",", "delay", ",", "TimeUnit", ".", "MILLISECONDS", ")", ")", ";", "}", "}" ]
Recalculates the next timeout checking time. @param minTimeoutAt next / closest timestamp
[ "Recalculates", "the", "next", "timeout", "checking", "time", "." ]
27575c44b9ecacc17c4456ceacf5d1851abf1cc4
https://github.com/moleculer-java/moleculer-java/blob/27575c44b9ecacc17c4456ceacf5d1851abf1cc4/src/main/java/services/moleculer/service/DefaultServiceRegistry.java#L383-L445
138,010
moleculer-java/moleculer-java
src/main/java/services/moleculer/transporter/TcpTransporter.java
TcpTransporter.generateGossipHello
public byte[] generateGossipHello() { if (cachedHelloMessage != null) { return cachedHelloMessage; } try { FastBuildTree root = new FastBuildTree(4); root.putUnsafe("ver", ServiceBroker.PROTOCOL_VERSION); root.putUnsafe("sender", nodeID); if (useHostname) { root.putUnsafe("host", getHostName()); } else { root.putUnsafe("host", InetAddress.getLocalHost().getHostAddress()); } root.putUnsafe("port", reader.getCurrentPort()); cachedHelloMessage = serialize(PACKET_GOSSIP_HELLO_ID, root); } catch (Exception error) { throw new MoleculerError("Unable to create HELLO message!", error, "MoleculerError", "unknown", false, 500, "UNABLE_TO_CREATE_HELLO"); } return cachedHelloMessage; }
java
public byte[] generateGossipHello() { if (cachedHelloMessage != null) { return cachedHelloMessage; } try { FastBuildTree root = new FastBuildTree(4); root.putUnsafe("ver", ServiceBroker.PROTOCOL_VERSION); root.putUnsafe("sender", nodeID); if (useHostname) { root.putUnsafe("host", getHostName()); } else { root.putUnsafe("host", InetAddress.getLocalHost().getHostAddress()); } root.putUnsafe("port", reader.getCurrentPort()); cachedHelloMessage = serialize(PACKET_GOSSIP_HELLO_ID, root); } catch (Exception error) { throw new MoleculerError("Unable to create HELLO message!", error, "MoleculerError", "unknown", false, 500, "UNABLE_TO_CREATE_HELLO"); } return cachedHelloMessage; }
[ "public", "byte", "[", "]", "generateGossipHello", "(", ")", "{", "if", "(", "cachedHelloMessage", "!=", "null", ")", "{", "return", "cachedHelloMessage", ";", "}", "try", "{", "FastBuildTree", "root", "=", "new", "FastBuildTree", "(", "4", ")", ";", "root", ".", "putUnsafe", "(", "\"ver\"", ",", "ServiceBroker", ".", "PROTOCOL_VERSION", ")", ";", "root", ".", "putUnsafe", "(", "\"sender\"", ",", "nodeID", ")", ";", "if", "(", "useHostname", ")", "{", "root", ".", "putUnsafe", "(", "\"host\"", ",", "getHostName", "(", ")", ")", ";", "}", "else", "{", "root", ".", "putUnsafe", "(", "\"host\"", ",", "InetAddress", ".", "getLocalHost", "(", ")", ".", "getHostAddress", "(", ")", ")", ";", "}", "root", ".", "putUnsafe", "(", "\"port\"", ",", "reader", ".", "getCurrentPort", "(", ")", ")", ";", "cachedHelloMessage", "=", "serialize", "(", "PACKET_GOSSIP_HELLO_ID", ",", "root", ")", ";", "}", "catch", "(", "Exception", "error", ")", "{", "throw", "new", "MoleculerError", "(", "\"Unable to create HELLO message!\"", ",", "error", ",", "\"MoleculerError\"", ",", "\"unknown\"", ",", "false", ",", "500", ",", "\"UNABLE_TO_CREATE_HELLO\"", ")", ";", "}", "return", "cachedHelloMessage", ";", "}" ]
Create Gossip HELLO packet. Hello message is invariable, so we can cache it. @return created "hello" request
[ "Create", "Gossip", "HELLO", "packet", ".", "Hello", "message", "is", "invariable", "so", "we", "can", "cache", "it", "." ]
27575c44b9ecacc17c4456ceacf5d1851abf1cc4
https://github.com/moleculer-java/moleculer-java/blob/27575c44b9ecacc17c4456ceacf5d1851abf1cc4/src/main/java/services/moleculer/transporter/TcpTransporter.java#L1332-L1352
138,011
moleculer-java/moleculer-java
src/main/java/services/moleculer/ServiceBroker.java
ServiceBroker.use
public ServiceBroker use(Collection<Middleware> middlewares) { if (serviceRegistry == null) { // Apply middlewares later this.middlewares.addAll(middlewares); } else { // Apply middlewares now serviceRegistry.use(middlewares); } return this; }
java
public ServiceBroker use(Collection<Middleware> middlewares) { if (serviceRegistry == null) { // Apply middlewares later this.middlewares.addAll(middlewares); } else { // Apply middlewares now serviceRegistry.use(middlewares); } return this; }
[ "public", "ServiceBroker", "use", "(", "Collection", "<", "Middleware", ">", "middlewares", ")", "{", "if", "(", "serviceRegistry", "==", "null", ")", "{", "// Apply middlewares later", "this", ".", "middlewares", ".", "addAll", "(", "middlewares", ")", ";", "}", "else", "{", "// Apply middlewares now", "serviceRegistry", ".", "use", "(", "middlewares", ")", ";", "}", "return", "this", ";", "}" ]
Installs a collection of middlewares. @param middlewares collection of middlewares @return this ServiceBroker instance (from "method chaining")
[ "Installs", "a", "collection", "of", "middlewares", "." ]
27575c44b9ecacc17c4456ceacf5d1851abf1cc4
https://github.com/moleculer-java/moleculer-java/blob/27575c44b9ecacc17c4456ceacf5d1851abf1cc4/src/main/java/services/moleculer/ServiceBroker.java#L652-L663
138,012
moleculer-java/moleculer-java
src/main/java/services/moleculer/ServiceBroker.java
ServiceBroker.getAction
public Action getAction(String actionName, String nodeID) { return serviceRegistry.getAction(actionName, nodeID); }
java
public Action getAction(String actionName, String nodeID) { return serviceRegistry.getAction(actionName, nodeID); }
[ "public", "Action", "getAction", "(", "String", "actionName", ",", "String", "nodeID", ")", "{", "return", "serviceRegistry", ".", "getAction", "(", "actionName", ",", "nodeID", ")", ";", "}" ]
Returns an action by name and nodeID. @param actionName name of the action (in "service.action" syntax, eg. "math.add") @param nodeID node identifier where the service is located @return local or remote action container
[ "Returns", "an", "action", "by", "name", "and", "nodeID", "." ]
27575c44b9ecacc17c4456ceacf5d1851abf1cc4
https://github.com/moleculer-java/moleculer-java/blob/27575c44b9ecacc17c4456ceacf5d1851abf1cc4/src/main/java/services/moleculer/ServiceBroker.java#L702-L704
138,013
moleculer-java/moleculer-java
src/main/java/services/moleculer/util/redis/RedisGetSetClient.java
RedisGetSetClient.get
public final Promise get(String key) { byte[] binaryKey = key.getBytes(StandardCharsets.UTF_8); if (client != null) { return new Promise(client.get(binaryKey)); } if (clusteredClient != null) { return new Promise(clusteredClient.get(binaryKey)); } return Promise.resolve(); }
java
public final Promise get(String key) { byte[] binaryKey = key.getBytes(StandardCharsets.UTF_8); if (client != null) { return new Promise(client.get(binaryKey)); } if (clusteredClient != null) { return new Promise(clusteredClient.get(binaryKey)); } return Promise.resolve(); }
[ "public", "final", "Promise", "get", "(", "String", "key", ")", "{", "byte", "[", "]", "binaryKey", "=", "key", ".", "getBytes", "(", "StandardCharsets", ".", "UTF_8", ")", ";", "if", "(", "client", "!=", "null", ")", "{", "return", "new", "Promise", "(", "client", ".", "get", "(", "binaryKey", ")", ")", ";", "}", "if", "(", "clusteredClient", "!=", "null", ")", "{", "return", "new", "Promise", "(", "clusteredClient", ".", "get", "(", "binaryKey", ")", ")", ";", "}", "return", "Promise", ".", "resolve", "(", ")", ";", "}" ]
Gets a content by a key. @param key cache key @return Promise with cached value (or null, the returned Promise also can be null)
[ "Gets", "a", "content", "by", "a", "key", "." ]
27575c44b9ecacc17c4456ceacf5d1851abf1cc4
https://github.com/moleculer-java/moleculer-java/blob/27575c44b9ecacc17c4456ceacf5d1851abf1cc4/src/main/java/services/moleculer/util/redis/RedisGetSetClient.java#L98-L107
138,014
moleculer-java/moleculer-java
src/main/java/services/moleculer/util/redis/RedisGetSetClient.java
RedisGetSetClient.set
public final Promise set(String key, byte[] value, SetArgs args) { byte[] binaryKey = key.getBytes(StandardCharsets.UTF_8); if (client != null) { if (args == null) { return new Promise(client.set(binaryKey, value)); } return new Promise(client.set(binaryKey, value, args)); } if (clusteredClient != null) { if (args == null) { return new Promise(clusteredClient.set(binaryKey, value)); } return new Promise(clusteredClient.set(binaryKey, value, args)); } return Promise.resolve(); }
java
public final Promise set(String key, byte[] value, SetArgs args) { byte[] binaryKey = key.getBytes(StandardCharsets.UTF_8); if (client != null) { if (args == null) { return new Promise(client.set(binaryKey, value)); } return new Promise(client.set(binaryKey, value, args)); } if (clusteredClient != null) { if (args == null) { return new Promise(clusteredClient.set(binaryKey, value)); } return new Promise(clusteredClient.set(binaryKey, value, args)); } return Promise.resolve(); }
[ "public", "final", "Promise", "set", "(", "String", "key", ",", "byte", "[", "]", "value", ",", "SetArgs", "args", ")", "{", "byte", "[", "]", "binaryKey", "=", "key", ".", "getBytes", "(", "StandardCharsets", ".", "UTF_8", ")", ";", "if", "(", "client", "!=", "null", ")", "{", "if", "(", "args", "==", "null", ")", "{", "return", "new", "Promise", "(", "client", ".", "set", "(", "binaryKey", ",", "value", ")", ")", ";", "}", "return", "new", "Promise", "(", "client", ".", "set", "(", "binaryKey", ",", "value", ",", "args", ")", ")", ";", "}", "if", "(", "clusteredClient", "!=", "null", ")", "{", "if", "(", "args", "==", "null", ")", "{", "return", "new", "Promise", "(", "clusteredClient", ".", "set", "(", "binaryKey", ",", "value", ")", ")", ";", "}", "return", "new", "Promise", "(", "clusteredClient", ".", "set", "(", "binaryKey", ",", "value", ",", "args", ")", ")", ";", "}", "return", "Promise", ".", "resolve", "(", ")", ";", "}" ]
Sets a content by key. @param key cache key @param value new value @param args Redis arguments (eg. TTL) @return Promise with empty value
[ "Sets", "a", "content", "by", "key", "." ]
27575c44b9ecacc17c4456ceacf5d1851abf1cc4
https://github.com/moleculer-java/moleculer-java/blob/27575c44b9ecacc17c4456ceacf5d1851abf1cc4/src/main/java/services/moleculer/util/redis/RedisGetSetClient.java#L121-L136
138,015
moleculer-java/moleculer-java
src/main/java/services/moleculer/util/redis/RedisGetSetClient.java
RedisGetSetClient.clean
public final Promise clean(String match) { ScanArgs args = new ScanArgs(); args.limit(100); boolean singleStar = match.indexOf('*') > -1; boolean doubleStar = match.contains("**"); if (doubleStar) { args.match(match.replace("**", "*")); } else if (singleStar) { if (match.length() > 1 && match.indexOf('.') == -1) { match += '*'; } args.match(match); } else { args.match(match); } if (!singleStar || doubleStar) { match = null; } if (client != null) { return new Promise(clean(client.scan(args), args, match)); } if (clusteredClient != null) { return new Promise(clean(clusteredClient.scan(args), args, match)); } return Promise.resolve(); }
java
public final Promise clean(String match) { ScanArgs args = new ScanArgs(); args.limit(100); boolean singleStar = match.indexOf('*') > -1; boolean doubleStar = match.contains("**"); if (doubleStar) { args.match(match.replace("**", "*")); } else if (singleStar) { if (match.length() > 1 && match.indexOf('.') == -1) { match += '*'; } args.match(match); } else { args.match(match); } if (!singleStar || doubleStar) { match = null; } if (client != null) { return new Promise(clean(client.scan(args), args, match)); } if (clusteredClient != null) { return new Promise(clean(clusteredClient.scan(args), args, match)); } return Promise.resolve(); }
[ "public", "final", "Promise", "clean", "(", "String", "match", ")", "{", "ScanArgs", "args", "=", "new", "ScanArgs", "(", ")", ";", "args", ".", "limit", "(", "100", ")", ";", "boolean", "singleStar", "=", "match", ".", "indexOf", "(", "'", "'", ")", ">", "-", "1", ";", "boolean", "doubleStar", "=", "match", ".", "contains", "(", "\"**\"", ")", ";", "if", "(", "doubleStar", ")", "{", "args", ".", "match", "(", "match", ".", "replace", "(", "\"**\"", ",", "\"*\"", ")", ")", ";", "}", "else", "if", "(", "singleStar", ")", "{", "if", "(", "match", ".", "length", "(", ")", ">", "1", "&&", "match", ".", "indexOf", "(", "'", "'", ")", "==", "-", "1", ")", "{", "match", "+=", "'", "'", ";", "}", "args", ".", "match", "(", "match", ")", ";", "}", "else", "{", "args", ".", "match", "(", "match", ")", ";", "}", "if", "(", "!", "singleStar", "||", "doubleStar", ")", "{", "match", "=", "null", ";", "}", "if", "(", "client", "!=", "null", ")", "{", "return", "new", "Promise", "(", "clean", "(", "client", ".", "scan", "(", "args", ")", ",", "args", ",", "match", ")", ")", ";", "}", "if", "(", "clusteredClient", "!=", "null", ")", "{", "return", "new", "Promise", "(", "clean", "(", "clusteredClient", ".", "scan", "(", "args", ")", ",", "args", ",", "match", ")", ")", ";", "}", "return", "Promise", ".", "resolve", "(", ")", ";", "}" ]
Deletes a group of items. Removes every key by a match string. @param match regex @return Promise with empty value
[ "Deletes", "a", "group", "of", "items", ".", "Removes", "every", "key", "by", "a", "match", "string", "." ]
27575c44b9ecacc17c4456ceacf5d1851abf1cc4
https://github.com/moleculer-java/moleculer-java/blob/27575c44b9ecacc17c4456ceacf5d1851abf1cc4/src/main/java/services/moleculer/util/redis/RedisGetSetClient.java#L165-L190
138,016
moleculer-java/moleculer-java
src/main/java/services/moleculer/monitor/Monitor.java
Monitor.getTotalCpuPercent
public int getTotalCpuPercent() { if (invalidMonitor.get()) { return 0; } long now = System.currentTimeMillis(); int cpu; synchronized (Monitor.class) { if (now - cpuDetectedAt > cacheTimeout) { try { cachedCPU = detectTotalCpuPercent(); } catch (Throwable cause) { logger.info("Unable to detect CPU usage!", cause); invalidMonitor.set(true); } cpuDetectedAt = now; } cpu = cachedCPU; } return cpu; }
java
public int getTotalCpuPercent() { if (invalidMonitor.get()) { return 0; } long now = System.currentTimeMillis(); int cpu; synchronized (Monitor.class) { if (now - cpuDetectedAt > cacheTimeout) { try { cachedCPU = detectTotalCpuPercent(); } catch (Throwable cause) { logger.info("Unable to detect CPU usage!", cause); invalidMonitor.set(true); } cpuDetectedAt = now; } cpu = cachedCPU; } return cpu; }
[ "public", "int", "getTotalCpuPercent", "(", ")", "{", "if", "(", "invalidMonitor", ".", "get", "(", ")", ")", "{", "return", "0", ";", "}", "long", "now", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "int", "cpu", ";", "synchronized", "(", "Monitor", ".", "class", ")", "{", "if", "(", "now", "-", "cpuDetectedAt", ">", "cacheTimeout", ")", "{", "try", "{", "cachedCPU", "=", "detectTotalCpuPercent", "(", ")", ";", "}", "catch", "(", "Throwable", "cause", ")", "{", "logger", ".", "info", "(", "\"Unable to detect CPU usage!\"", ",", "cause", ")", ";", "invalidMonitor", ".", "set", "(", "true", ")", ";", "}", "cpuDetectedAt", "=", "now", ";", "}", "cpu", "=", "cachedCPU", ";", "}", "return", "cpu", ";", "}" ]
Returns the cached system CPU usage, in percents, between 0 and 100. @return total CPU usage of the current OS
[ "Returns", "the", "cached", "system", "CPU", "usage", "in", "percents", "between", "0", "and", "100", "." ]
27575c44b9ecacc17c4456ceacf5d1851abf1cc4
https://github.com/moleculer-java/moleculer-java/blob/27575c44b9ecacc17c4456ceacf5d1851abf1cc4/src/main/java/services/moleculer/monitor/Monitor.java#L82-L101
138,017
moleculer-java/moleculer-java
src/main/java/services/moleculer/monitor/Monitor.java
Monitor.getPID
public long getPID() { long currentPID = cachedPID.get(); if (currentPID != 0) { return currentPID; } try { currentPID = detectPID(); } catch (Throwable cause) { logger.info("Unable to detect process ID!", cause); } if (currentPID == 0) { currentPID = System.nanoTime(); if (!cachedPID.compareAndSet(0, currentPID)) { currentPID = cachedPID.get(); } } else { cachedPID.set(currentPID); } return currentPID; }
java
public long getPID() { long currentPID = cachedPID.get(); if (currentPID != 0) { return currentPID; } try { currentPID = detectPID(); } catch (Throwable cause) { logger.info("Unable to detect process ID!", cause); } if (currentPID == 0) { currentPID = System.nanoTime(); if (!cachedPID.compareAndSet(0, currentPID)) { currentPID = cachedPID.get(); } } else { cachedPID.set(currentPID); } return currentPID; }
[ "public", "long", "getPID", "(", ")", "{", "long", "currentPID", "=", "cachedPID", ".", "get", "(", ")", ";", "if", "(", "currentPID", "!=", "0", ")", "{", "return", "currentPID", ";", "}", "try", "{", "currentPID", "=", "detectPID", "(", ")", ";", "}", "catch", "(", "Throwable", "cause", ")", "{", "logger", ".", "info", "(", "\"Unable to detect process ID!\"", ",", "cause", ")", ";", "}", "if", "(", "currentPID", "==", "0", ")", "{", "currentPID", "=", "System", ".", "nanoTime", "(", ")", ";", "if", "(", "!", "cachedPID", ".", "compareAndSet", "(", "0", ",", "currentPID", ")", ")", "{", "currentPID", "=", "cachedPID", ".", "get", "(", ")", ";", "}", "}", "else", "{", "cachedPID", ".", "set", "(", "currentPID", ")", ";", "}", "return", "currentPID", ";", "}" ]
Returns the cached PID of Java VM. @return current Java VM's process ID
[ "Returns", "the", "cached", "PID", "of", "Java", "VM", "." ]
27575c44b9ecacc17c4456ceacf5d1851abf1cc4
https://github.com/moleculer-java/moleculer-java/blob/27575c44b9ecacc17c4456ceacf5d1851abf1cc4/src/main/java/services/moleculer/monitor/Monitor.java#L108-L127
138,018
moleculer-java/moleculer-java
src/main/java/services/moleculer/stream/IncomingStream.java
IncomingStream.reset
public synchronized void reset() { timeoutAt = 0; prevSeq = -1; pool.clear(); stream.closed.set(false); stream.buffer.clear(); stream.cause = null; stream.transferedBytes.set(0); inited.set(false); }
java
public synchronized void reset() { timeoutAt = 0; prevSeq = -1; pool.clear(); stream.closed.set(false); stream.buffer.clear(); stream.cause = null; stream.transferedBytes.set(0); inited.set(false); }
[ "public", "synchronized", "void", "reset", "(", ")", "{", "timeoutAt", "=", "0", ";", "prevSeq", "=", "-", "1", ";", "pool", ".", "clear", "(", ")", ";", "stream", ".", "closed", ".", "set", "(", "false", ")", ";", "stream", ".", "buffer", ".", "clear", "(", ")", ";", "stream", ".", "cause", "=", "null", ";", "stream", ".", "transferedBytes", ".", "set", "(", "0", ")", ";", "inited", ".", "set", "(", "false", ")", ";", "}" ]
Used for testing. Resets internal variables.
[ "Used", "for", "testing", ".", "Resets", "internal", "variables", "." ]
27575c44b9ecacc17c4456ceacf5d1851abf1cc4
https://github.com/moleculer-java/moleculer-java/blob/27575c44b9ecacc17c4456ceacf5d1851abf1cc4/src/main/java/services/moleculer/stream/IncomingStream.java#L83-L92
138,019
moleculer-java/moleculer-java
src/main/java/services/moleculer/uid/IncrementalUidGenerator.java
IncrementalUidGenerator.started
@Override public void started(ServiceBroker broker) throws Exception { super.started(broker); if (prefix == null) { prefix = (broker.getNodeID() + ':').toCharArray(); } }
java
@Override public void started(ServiceBroker broker) throws Exception { super.started(broker); if (prefix == null) { prefix = (broker.getNodeID() + ':').toCharArray(); } }
[ "@", "Override", "public", "void", "started", "(", "ServiceBroker", "broker", ")", "throws", "Exception", "{", "super", ".", "started", "(", "broker", ")", ";", "if", "(", "prefix", "==", "null", ")", "{", "prefix", "=", "(", "broker", ".", "getNodeID", "(", ")", "+", "'", "'", ")", ".", "toCharArray", "(", ")", ";", "}", "}" ]
Initializes UID generator instance. @param broker parent ServiceBroker
[ "Initializes", "UID", "generator", "instance", "." ]
27575c44b9ecacc17c4456ceacf5d1851abf1cc4
https://github.com/moleculer-java/moleculer-java/blob/27575c44b9ecacc17c4456ceacf5d1851abf1cc4/src/main/java/services/moleculer/uid/IncrementalUidGenerator.java#L63-L69
138,020
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/client/ApplicationSession.java
ApplicationSession.updateSchema
public boolean updateSchema(String text, ContentType contentType) { Utils.require(text != null && text.length() > 0, "text"); Utils.require(contentType != null, "contentType"); try { // Send a PUT request to "/_applications/{application}". byte[] body = Utils.toBytes(text); StringBuilder uri = new StringBuilder("/_applications/"); uri.append(Utils.urlEncode(m_appDef.getAppName())); RESTResponse response = m_restClient.sendRequest(HttpMethod.PUT, uri.toString(), contentType, body); m_logger.debug("updateSchema() response: {}", response.toString()); throwIfErrorResponse(response); return true; } catch (Exception e) { throw new RuntimeException(e); } }
java
public boolean updateSchema(String text, ContentType contentType) { Utils.require(text != null && text.length() > 0, "text"); Utils.require(contentType != null, "contentType"); try { // Send a PUT request to "/_applications/{application}". byte[] body = Utils.toBytes(text); StringBuilder uri = new StringBuilder("/_applications/"); uri.append(Utils.urlEncode(m_appDef.getAppName())); RESTResponse response = m_restClient.sendRequest(HttpMethod.PUT, uri.toString(), contentType, body); m_logger.debug("updateSchema() response: {}", response.toString()); throwIfErrorResponse(response); return true; } catch (Exception e) { throw new RuntimeException(e); } }
[ "public", "boolean", "updateSchema", "(", "String", "text", ",", "ContentType", "contentType", ")", "{", "Utils", ".", "require", "(", "text", "!=", "null", "&&", "text", ".", "length", "(", ")", ">", "0", ",", "\"text\"", ")", ";", "Utils", ".", "require", "(", "contentType", "!=", "null", ",", "\"contentType\"", ")", ";", "try", "{", "// Send a PUT request to \"/_applications/{application}\".\r", "byte", "[", "]", "body", "=", "Utils", ".", "toBytes", "(", "text", ")", ";", "StringBuilder", "uri", "=", "new", "StringBuilder", "(", "\"/_applications/\"", ")", ";", "uri", ".", "append", "(", "Utils", ".", "urlEncode", "(", "m_appDef", ".", "getAppName", "(", ")", ")", ")", ";", "RESTResponse", "response", "=", "m_restClient", ".", "sendRequest", "(", "HttpMethod", ".", "PUT", ",", "uri", ".", "toString", "(", ")", ",", "contentType", ",", "body", ")", ";", "m_logger", ".", "debug", "(", "\"updateSchema() response: {}\"", ",", "response", ".", "toString", "(", ")", ")", ";", "throwIfErrorResponse", "(", "response", ")", ";", "return", "true", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Update the schema for this session's application with the given definition. The text must be formatted in XML or JSON, as defined by the given content type. True is returned if the update was successful. An exception is thrown if an error occurred. @param text Text of updated schema definition. @param contentType Format of text. Must be {@link ContentType#APPLICATION_JSON} or {@link ContentType#TEXT_XML}. @return True if the schema update was successful.
[ "Update", "the", "schema", "for", "this", "session", "s", "application", "with", "the", "given", "definition", ".", "The", "text", "must", "be", "formatted", "in", "XML", "or", "JSON", "as", "defined", "by", "the", "given", "content", "type", ".", "True", "is", "returned", "if", "the", "update", "was", "successful", ".", "An", "exception", "is", "thrown", "if", "an", "error", "occurred", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/ApplicationSession.java#L135-L152
138,021
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/client/ApplicationSession.java
ApplicationSession.throwIfErrorResponse
protected void throwIfErrorResponse(RESTResponse response) { if (response.getCode().isError()) { String errMsg = response.getBody(); if (Utils.isEmpty(errMsg)) { errMsg = "Unknown error; response code: " + response.getCode(); } throw new RuntimeException(errMsg); } }
java
protected void throwIfErrorResponse(RESTResponse response) { if (response.getCode().isError()) { String errMsg = response.getBody(); if (Utils.isEmpty(errMsg)) { errMsg = "Unknown error; response code: " + response.getCode(); } throw new RuntimeException(errMsg); } }
[ "protected", "void", "throwIfErrorResponse", "(", "RESTResponse", "response", ")", "{", "if", "(", "response", ".", "getCode", "(", ")", ".", "isError", "(", ")", ")", "{", "String", "errMsg", "=", "response", ".", "getBody", "(", ")", ";", "if", "(", "Utils", ".", "isEmpty", "(", "errMsg", ")", ")", "{", "errMsg", "=", "\"Unknown error; response code: \"", "+", "response", ".", "getCode", "(", ")", ";", "}", "throw", "new", "RuntimeException", "(", "errMsg", ")", ";", "}", "}" ]
If the given response shows an error, throw a RuntimeException using its text.
[ "If", "the", "given", "response", "shows", "an", "error", "throw", "a", "RuntimeException", "using", "its", "text", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/ApplicationSession.java#L265-L273
138,022
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/olap/ParsedQuery.java
ParsedQuery.get
public String get(String key) { if(requestedKeys == null) requestedKeys = new HashSet<String>(); String value = map.get(key); requestedKeys.add(key); return value; }
java
public String get(String key) { if(requestedKeys == null) requestedKeys = new HashSet<String>(); String value = map.get(key); requestedKeys.add(key); return value; }
[ "public", "String", "get", "(", "String", "key", ")", "{", "if", "(", "requestedKeys", "==", "null", ")", "requestedKeys", "=", "new", "HashSet", "<", "String", ">", "(", ")", ";", "String", "value", "=", "map", ".", "get", "(", "key", ")", ";", "requestedKeys", ".", "add", "(", "key", ")", ";", "return", "value", ";", "}" ]
Gets a value by the key specified. Returns null if the key does not exist.
[ "Gets", "a", "value", "by", "the", "key", "specified", ".", "Returns", "null", "if", "the", "key", "does", "not", "exist", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/olap/ParsedQuery.java#L80-L85
138,023
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/olap/ParsedQuery.java
ParsedQuery.getString
public String getString(String key) { String value = get(key); Utils.require(value != null, key + " parameter is not set"); return value; }
java
public String getString(String key) { String value = get(key); Utils.require(value != null, key + " parameter is not set"); return value; }
[ "public", "String", "getString", "(", "String", "key", ")", "{", "String", "value", "=", "get", "(", "key", ")", ";", "Utils", ".", "require", "(", "value", "!=", "null", ",", "key", "+", "\" parameter is not set\"", ")", ";", "return", "value", ";", "}" ]
Gets a value by the key specified. Unlike 'get', checks that the parameter is not null
[ "Gets", "a", "value", "by", "the", "key", "specified", ".", "Unlike", "get", "checks", "that", "the", "parameter", "is", "not", "null" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/olap/ParsedQuery.java#L90-L94
138,024
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/olap/ParsedQuery.java
ParsedQuery.getInt
public int getInt(String key) { String value = get(key); Utils.require(value != null, key + " parameter is not set"); try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new IllegalArgumentException(key + " parameter should be a number"); } }
java
public int getInt(String key) { String value = get(key); Utils.require(value != null, key + " parameter is not set"); try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new IllegalArgumentException(key + " parameter should be a number"); } }
[ "public", "int", "getInt", "(", "String", "key", ")", "{", "String", "value", "=", "get", "(", "key", ")", ";", "Utils", ".", "require", "(", "value", "!=", "null", ",", "key", "+", "\" parameter is not set\"", ")", ";", "try", "{", "return", "Integer", ".", "parseInt", "(", "value", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "throw", "new", "IllegalArgumentException", "(", "key", "+", "\" parameter should be a number\"", ")", ";", "}", "}" ]
Returns an integer value by the key specified and throws exception if it was not specified
[ "Returns", "an", "integer", "value", "by", "the", "key", "specified", "and", "throws", "exception", "if", "it", "was", "not", "specified" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/olap/ParsedQuery.java#L110-L118
138,025
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/olap/ParsedQuery.java
ParsedQuery.getInt
public int getInt(String key, int defaultValue) { String value = get(key); if(value == null) return defaultValue; try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new IllegalArgumentException(key + " parameter should be a number"); } }
java
public int getInt(String key, int defaultValue) { String value = get(key); if(value == null) return defaultValue; try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new IllegalArgumentException(key + " parameter should be a number"); } }
[ "public", "int", "getInt", "(", "String", "key", ",", "int", "defaultValue", ")", "{", "String", "value", "=", "get", "(", "key", ")", ";", "if", "(", "value", "==", "null", ")", "return", "defaultValue", ";", "try", "{", "return", "Integer", ".", "parseInt", "(", "value", ")", ";", "}", "catch", "(", "NumberFormatException", "e", ")", "{", "throw", "new", "IllegalArgumentException", "(", "key", "+", "\" parameter should be a number\"", ")", ";", "}", "}" ]
Returns an integer value by the key specified or defaultValue if the key was not provided
[ "Returns", "an", "integer", "value", "by", "the", "key", "specified", "or", "defaultValue", "if", "the", "key", "was", "not", "provided" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/olap/ParsedQuery.java#L123-L131
138,026
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/olap/ParsedQuery.java
ParsedQuery.getBoolean
public boolean getBoolean(String key, boolean defaultValue) { String value = get(key); if(value == null) return defaultValue; return XType.getBoolean(value); }
java
public boolean getBoolean(String key, boolean defaultValue) { String value = get(key); if(value == null) return defaultValue; return XType.getBoolean(value); }
[ "public", "boolean", "getBoolean", "(", "String", "key", ",", "boolean", "defaultValue", ")", "{", "String", "value", "=", "get", "(", "key", ")", ";", "if", "(", "value", "==", "null", ")", "return", "defaultValue", ";", "return", "XType", ".", "getBoolean", "(", "value", ")", ";", "}" ]
Returns a boolean value by the key specified or defaultValue if the key was not provided
[ "Returns", "a", "boolean", "value", "by", "the", "key", "specified", "or", "defaultValue", "if", "the", "key", "was", "not", "provided" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/olap/ParsedQuery.java#L136-L140
138,027
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/olap/ParsedQuery.java
ParsedQuery.checkInvalidParameters
public void checkInvalidParameters() { for(String key: map.keySet()) { boolean wasRequested = requestedKeys != null && requestedKeys.contains(key); if(!wasRequested) throw new IllegalArgumentException("Unknown parameter " + key); } }
java
public void checkInvalidParameters() { for(String key: map.keySet()) { boolean wasRequested = requestedKeys != null && requestedKeys.contains(key); if(!wasRequested) throw new IllegalArgumentException("Unknown parameter " + key); } }
[ "public", "void", "checkInvalidParameters", "(", ")", "{", "for", "(", "String", "key", ":", "map", ".", "keySet", "(", ")", ")", "{", "boolean", "wasRequested", "=", "requestedKeys", "!=", "null", "&&", "requestedKeys", ".", "contains", "(", "key", ")", ";", "if", "(", "!", "wasRequested", ")", "throw", "new", "IllegalArgumentException", "(", "\"Unknown parameter \"", "+", "key", ")", ";", "}", "}" ]
Checks that there are no more parameters than those that have ever been requested. Call this after you processed all parameters you need if you want an IllegalArgumentException to be thrown if there are more parameters
[ "Checks", "that", "there", "are", "no", "more", "parameters", "than", "those", "that", "have", "ever", "been", "requested", ".", "Call", "this", "after", "you", "processed", "all", "parameters", "you", "need", "if", "you", "want", "an", "IllegalArgumentException", "to", "be", "thrown", "if", "there", "are", "more", "parameters" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/olap/ParsedQuery.java#L148-L154
138,028
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/thrift/CassandraDefs.java
CassandraDefs.keyRangeStartRow
static KeyRange keyRangeStartRow(byte[] startRowKey) { KeyRange keyRange = new KeyRange(); keyRange.setStart_key(startRowKey); keyRange.setEnd_key(EMPTY_BYTE_BUFFER); keyRange.setCount(MAX_ROWS_BATCH_SIZE); return keyRange; }
java
static KeyRange keyRangeStartRow(byte[] startRowKey) { KeyRange keyRange = new KeyRange(); keyRange.setStart_key(startRowKey); keyRange.setEnd_key(EMPTY_BYTE_BUFFER); keyRange.setCount(MAX_ROWS_BATCH_SIZE); return keyRange; }
[ "static", "KeyRange", "keyRangeStartRow", "(", "byte", "[", "]", "startRowKey", ")", "{", "KeyRange", "keyRange", "=", "new", "KeyRange", "(", ")", ";", "keyRange", ".", "setStart_key", "(", "startRowKey", ")", ";", "keyRange", ".", "setEnd_key", "(", "EMPTY_BYTE_BUFFER", ")", ";", "keyRange", ".", "setCount", "(", "MAX_ROWS_BATCH_SIZE", ")", ";", "return", "keyRange", ";", "}" ]
Create a KeyRange that begins at the given row key. @param startRowKey Starting row key as a byte[]. @return KeyRange that starts at the given row, open-ended.
[ "Create", "a", "KeyRange", "that", "begins", "at", "the", "given", "row", "key", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/thrift/CassandraDefs.java#L115-L121
138,029
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/thrift/CassandraDefs.java
CassandraDefs.keyRangeSingleRow
static KeyRange keyRangeSingleRow(byte[] rowKey) { KeyRange keyRange = new KeyRange(); keyRange.setStart_key(rowKey); keyRange.setEnd_key(rowKey); keyRange.setCount(1); return keyRange; }
java
static KeyRange keyRangeSingleRow(byte[] rowKey) { KeyRange keyRange = new KeyRange(); keyRange.setStart_key(rowKey); keyRange.setEnd_key(rowKey); keyRange.setCount(1); return keyRange; }
[ "static", "KeyRange", "keyRangeSingleRow", "(", "byte", "[", "]", "rowKey", ")", "{", "KeyRange", "keyRange", "=", "new", "KeyRange", "(", ")", ";", "keyRange", ".", "setStart_key", "(", "rowKey", ")", ";", "keyRange", ".", "setEnd_key", "(", "rowKey", ")", ";", "keyRange", ".", "setCount", "(", "1", ")", ";", "return", "keyRange", ";", "}" ]
Create a KeyRange that selects a single row with the given key. @param rowKey Row key as a byte[]. @return KeyRange that starts and ends with the given key.
[ "Create", "a", "KeyRange", "that", "selects", "a", "single", "row", "with", "the", "given", "key", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/thrift/CassandraDefs.java#L137-L143
138,030
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/thrift/CassandraDefs.java
CassandraDefs.slicePredicateColName
static SlicePredicate slicePredicateColName(byte[] colName) { SlicePredicate slicePred = new SlicePredicate(); slicePred.addToColumn_names(ByteBuffer.wrap(colName)); return slicePred; }
java
static SlicePredicate slicePredicateColName(byte[] colName) { SlicePredicate slicePred = new SlicePredicate(); slicePred.addToColumn_names(ByteBuffer.wrap(colName)); return slicePred; }
[ "static", "SlicePredicate", "slicePredicateColName", "(", "byte", "[", "]", "colName", ")", "{", "SlicePredicate", "slicePred", "=", "new", "SlicePredicate", "(", ")", ";", "slicePred", ".", "addToColumn_names", "(", "ByteBuffer", ".", "wrap", "(", "colName", ")", ")", ";", "return", "slicePred", ";", "}" ]
Create a SlicePredicate that selects a single column. @param colName Column name as a byte[]. @return SlicePredicate that select the given column name only.
[ "Create", "a", "SlicePredicate", "that", "selects", "a", "single", "column", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/thrift/CassandraDefs.java#L225-L229
138,031
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/thrift/CassandraDefs.java
CassandraDefs.slicePredicateColNames
static SlicePredicate slicePredicateColNames(Collection<byte[]> colNames) { SlicePredicate slicePred = new SlicePredicate(); for (byte[] colName : colNames) { slicePred.addToColumn_names(ByteBuffer.wrap(colName)); } return slicePred; }
java
static SlicePredicate slicePredicateColNames(Collection<byte[]> colNames) { SlicePredicate slicePred = new SlicePredicate(); for (byte[] colName : colNames) { slicePred.addToColumn_names(ByteBuffer.wrap(colName)); } return slicePred; }
[ "static", "SlicePredicate", "slicePredicateColNames", "(", "Collection", "<", "byte", "[", "]", ">", "colNames", ")", "{", "SlicePredicate", "slicePred", "=", "new", "SlicePredicate", "(", ")", ";", "for", "(", "byte", "[", "]", "colName", ":", "colNames", ")", "{", "slicePred", ".", "addToColumn_names", "(", "ByteBuffer", ".", "wrap", "(", "colName", ")", ")", ";", "}", "return", "slicePred", ";", "}" ]
Create a SlicePredicate that selects the given column names. @param colNames A collection of column names as byte[]s. @return SlicePredicate that selects the given column names only.
[ "Create", "a", "SlicePredicate", "that", "selects", "the", "given", "column", "names", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/thrift/CassandraDefs.java#L237-L243
138,032
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskRecord.java
TaskRecord.getTime
public Calendar getTime(String propName) { assert propName.endsWith("Time"); if (!m_properties.containsKey(propName)) { return null; } Calendar calendar = new GregorianCalendar(Utils.UTC_TIMEZONE); calendar.setTimeInMillis(Long.parseLong(m_properties.get(propName))); return calendar; }
java
public Calendar getTime(String propName) { assert propName.endsWith("Time"); if (!m_properties.containsKey(propName)) { return null; } Calendar calendar = new GregorianCalendar(Utils.UTC_TIMEZONE); calendar.setTimeInMillis(Long.parseLong(m_properties.get(propName))); return calendar; }
[ "public", "Calendar", "getTime", "(", "String", "propName", ")", "{", "assert", "propName", ".", "endsWith", "(", "\"Time\"", ")", ";", "if", "(", "!", "m_properties", ".", "containsKey", "(", "propName", ")", ")", "{", "return", "null", ";", "}", "Calendar", "calendar", "=", "new", "GregorianCalendar", "(", "Utils", ".", "UTC_TIMEZONE", ")", ";", "calendar", ".", "setTimeInMillis", "(", "Long", ".", "parseLong", "(", "m_properties", ".", "get", "(", "propName", ")", ")", ")", ";", "return", "calendar", ";", "}" ]
Get the value of a time property as a Calendar value. If the given property has not been set or is not a time value, null is returned. @param propName Name of a time-valued task record property to fetch. @return Time property value as a Calendar object in the UTC time zone.
[ "Get", "the", "value", "of", "a", "time", "property", "as", "a", "Calendar", "value", ".", "If", "the", "given", "property", "has", "not", "been", "set", "or", "is", "not", "a", "time", "value", "null", "is", "returned", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskRecord.java#L124-L132
138,033
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskRecord.java
TaskRecord.toDoc
public UNode toDoc() { UNode rootNode = UNode.createMapNode(m_taskID, "task"); for (String name : m_properties.keySet()) { String value = m_properties.get(name); if (name.endsWith("Time")) { rootNode.addValueNode(name, formatTimestamp(value)); } else { rootNode.addValueNode(name, value); } } return rootNode; }
java
public UNode toDoc() { UNode rootNode = UNode.createMapNode(m_taskID, "task"); for (String name : m_properties.keySet()) { String value = m_properties.get(name); if (name.endsWith("Time")) { rootNode.addValueNode(name, formatTimestamp(value)); } else { rootNode.addValueNode(name, value); } } return rootNode; }
[ "public", "UNode", "toDoc", "(", ")", "{", "UNode", "rootNode", "=", "UNode", ".", "createMapNode", "(", "m_taskID", ",", "\"task\"", ")", ";", "for", "(", "String", "name", ":", "m_properties", ".", "keySet", "(", ")", ")", "{", "String", "value", "=", "m_properties", ".", "get", "(", "name", ")", ";", "if", "(", "name", ".", "endsWith", "(", "\"Time\"", ")", ")", "{", "rootNode", ".", "addValueNode", "(", "name", ",", "formatTimestamp", "(", "value", ")", ")", ";", "}", "else", "{", "rootNode", ".", "addValueNode", "(", "name", ",", "value", ")", ";", "}", "}", "return", "rootNode", ";", "}" ]
Serialize this task record into a UNode tree. The root UNode is returned, which is a map containing one child value node for each TaskRecord property. The map's name is the task ID with a tag name of "task". Timestamp values are formatted into friendly display format. @return Root of a {@link UNode} tree.
[ "Serialize", "this", "task", "record", "into", "a", "UNode", "tree", ".", "The", "root", "UNode", "is", "returned", "which", "is", "a", "map", "containing", "one", "child", "value", "node", "for", "each", "TaskRecord", "property", ".", "The", "map", "s", "name", "is", "the", "task", "ID", "with", "a", "tag", "name", "of", "task", ".", "Timestamp", "values", "are", "formatted", "into", "friendly", "display", "format", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/taskmanager/TaskRecord.java#L183-L194
138,034
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/Service.java
Service.waitForFullService
public final void waitForFullService() { if (!m_state.isInitialized()) { throw new RuntimeException("Service has not been initialized"); } synchronized (m_stateChangeLock) { // Loop until state >= RUNNING while (!m_state.isRunning()) { try { m_stateChangeLock.wait(); } catch (InterruptedException e) { } } if (m_state.isStopping()) { throw new RuntimeException("Service " + this.getClass().getSimpleName() + " failed before reaching running state"); } } }
java
public final void waitForFullService() { if (!m_state.isInitialized()) { throw new RuntimeException("Service has not been initialized"); } synchronized (m_stateChangeLock) { // Loop until state >= RUNNING while (!m_state.isRunning()) { try { m_stateChangeLock.wait(); } catch (InterruptedException e) { } } if (m_state.isStopping()) { throw new RuntimeException("Service " + this.getClass().getSimpleName() + " failed before reaching running state"); } } }
[ "public", "final", "void", "waitForFullService", "(", ")", "{", "if", "(", "!", "m_state", ".", "isInitialized", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"Service has not been initialized\"", ")", ";", "}", "synchronized", "(", "m_stateChangeLock", ")", "{", "// Loop until state >= RUNNING\r", "while", "(", "!", "m_state", ".", "isRunning", "(", ")", ")", "{", "try", "{", "m_stateChangeLock", ".", "wait", "(", ")", ";", "}", "catch", "(", "InterruptedException", "e", ")", "{", "}", "}", "if", "(", "m_state", ".", "isStopping", "(", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"Service \"", "+", "this", ".", "getClass", "(", ")", ".", "getSimpleName", "(", ")", "+", "\" failed before reaching running state\"", ")", ";", "}", "}", "}" ]
Wait for this service to reach the running state then return. A RuntimeException is thrown if the service has not been initialized. @throws RuntimeException If this service has not been initialized.
[ "Wait", "for", "this", "service", "to", "reach", "the", "running", "state", "then", "return", ".", "A", "RuntimeException", "is", "thrown", "if", "the", "service", "has", "not", "been", "initialized", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/Service.java#L228-L245
138,035
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/Service.java
Service.getParamString
public String getParamString(String paramName) { Object paramValue = getParam(paramName); if (paramValue == null) { return null; } return paramValue.toString(); }
java
public String getParamString(String paramName) { Object paramValue = getParam(paramName); if (paramValue == null) { return null; } return paramValue.toString(); }
[ "public", "String", "getParamString", "(", "String", "paramName", ")", "{", "Object", "paramValue", "=", "getParam", "(", "paramName", ")", ";", "if", "(", "paramValue", "==", "null", ")", "{", "return", "null", ";", "}", "return", "paramValue", ".", "toString", "(", ")", ";", "}" ]
Get the value of the parameter with the given name belonging to this service as a String. If the parameter is not found, null is returned. @param paramName Name of parameter to find. @return Parameter found as a String if found, otherwise null.
[ "Get", "the", "value", "of", "the", "parameter", "with", "the", "given", "name", "belonging", "to", "this", "service", "as", "a", "String", ".", "If", "the", "parameter", "is", "not", "found", "null", "is", "returned", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/Service.java#L275-L281
138,036
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/Service.java
Service.getParamInt
public int getParamInt(String paramName, int defaultValue) { Object paramValue = getParam(paramName); if (paramValue == null) { return defaultValue; } try { return Integer.parseInt(paramValue.toString()); } catch (Exception e) { throw new IllegalArgumentException("Value for parameter '" + paramName + "' must be an integer: " + paramValue); } }
java
public int getParamInt(String paramName, int defaultValue) { Object paramValue = getParam(paramName); if (paramValue == null) { return defaultValue; } try { return Integer.parseInt(paramValue.toString()); } catch (Exception e) { throw new IllegalArgumentException("Value for parameter '" + paramName + "' must be an integer: " + paramValue); } }
[ "public", "int", "getParamInt", "(", "String", "paramName", ",", "int", "defaultValue", ")", "{", "Object", "paramValue", "=", "getParam", "(", "paramName", ")", ";", "if", "(", "paramValue", "==", "null", ")", "{", "return", "defaultValue", ";", "}", "try", "{", "return", "Integer", ".", "parseInt", "(", "paramValue", ".", "toString", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Value for parameter '\"", "+", "paramName", "+", "\"' must be an integer: \"", "+", "paramValue", ")", ";", "}", "}" ]
Get the value of the parameter with the given name belonging to this service as an integer. If the parameter is not found, the given default value is returned. If the parameter is found but cannot be converted to an integer, an IllegalArgumentException is thrown. @param paramName Name of parameter to find. @param defaultValue Value to return if parameter is not defined. @return Defined or default value.
[ "Get", "the", "value", "of", "the", "parameter", "with", "the", "given", "name", "belonging", "to", "this", "service", "as", "an", "integer", ".", "If", "the", "parameter", "is", "not", "found", "the", "given", "default", "value", "is", "returned", ".", "If", "the", "parameter", "is", "found", "but", "cannot", "be", "converted", "to", "an", "integer", "an", "IllegalArgumentException", "is", "thrown", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/Service.java#L293-L303
138,037
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/Service.java
Service.getParamBoolean
public boolean getParamBoolean(String paramName) { Object paramValue = getParam(paramName); if (paramValue == null) { return false; } return Boolean.parseBoolean(paramValue.toString()); }
java
public boolean getParamBoolean(String paramName) { Object paramValue = getParam(paramName); if (paramValue == null) { return false; } return Boolean.parseBoolean(paramValue.toString()); }
[ "public", "boolean", "getParamBoolean", "(", "String", "paramName", ")", "{", "Object", "paramValue", "=", "getParam", "(", "paramName", ")", ";", "if", "(", "paramValue", "==", "null", ")", "{", "return", "false", ";", "}", "return", "Boolean", ".", "parseBoolean", "(", "paramValue", ".", "toString", "(", ")", ")", ";", "}" ]
Get the value of the parameter with the given name belonging to this service as a boolean. If the parameter is not found, false is returned. @param paramName Name of parameter to find. @return Parameter value found or false if not found.
[ "Get", "the", "value", "of", "the", "parameter", "with", "the", "given", "name", "belonging", "to", "this", "service", "as", "a", "boolean", ".", "If", "the", "parameter", "is", "not", "found", "false", "is", "returned", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/Service.java#L312-L318
138,038
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/Service.java
Service.getParamList
@SuppressWarnings("unchecked") public List<String> getParamList(String paramName) { Object paramValue = getParam(paramName); if (paramValue == null) { return null; } if (!(paramValue instanceof List)) { throw new IllegalArgumentException("Parameter '" + paramName + "' must be a list: " + paramValue); } return (List<String>)paramValue; }
java
@SuppressWarnings("unchecked") public List<String> getParamList(String paramName) { Object paramValue = getParam(paramName); if (paramValue == null) { return null; } if (!(paramValue instanceof List)) { throw new IllegalArgumentException("Parameter '" + paramName + "' must be a list: " + paramValue); } return (List<String>)paramValue; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "List", "<", "String", ">", "getParamList", "(", "String", "paramName", ")", "{", "Object", "paramValue", "=", "getParam", "(", "paramName", ")", ";", "if", "(", "paramValue", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "!", "(", "paramValue", "instanceof", "List", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Parameter '\"", "+", "paramName", "+", "\"' must be a list: \"", "+", "paramValue", ")", ";", "}", "return", "(", "List", "<", "String", ">", ")", "paramValue", ";", "}" ]
Get the value of the given parameter name belonging to this service as a LIst of Strings. If no such parameter name is known, null is returned. If the parameter is defined but is not a list, an IllegalArgumentException is thrown. @param paramName Name of parameter to get value of. @return Parameter value as a List of Strings or null if unknown.
[ "Get", "the", "value", "of", "the", "given", "parameter", "name", "belonging", "to", "this", "service", "as", "a", "LIst", "of", "Strings", ".", "If", "no", "such", "parameter", "name", "is", "known", "null", "is", "returned", ".", "If", "the", "parameter", "is", "defined", "but", "is", "not", "a", "list", "an", "IllegalArgumentException", "is", "thrown", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/Service.java#L343-L353
138,039
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/Service.java
Service.getParamMap
@SuppressWarnings("unchecked") public Map<String, Object> getParamMap(String paramName) { Object paramValue = getParam(paramName); if (paramValue == null) { return null; } if (!(paramValue instanceof Map)) { throw new IllegalArgumentException("Parameter '" + paramName + "' must be a map: " + paramValue); } return (Map<String, Object>)paramValue; }
java
@SuppressWarnings("unchecked") public Map<String, Object> getParamMap(String paramName) { Object paramValue = getParam(paramName); if (paramValue == null) { return null; } if (!(paramValue instanceof Map)) { throw new IllegalArgumentException("Parameter '" + paramName + "' must be a map: " + paramValue); } return (Map<String, Object>)paramValue; }
[ "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "public", "Map", "<", "String", ",", "Object", ">", "getParamMap", "(", "String", "paramName", ")", "{", "Object", "paramValue", "=", "getParam", "(", "paramName", ")", ";", "if", "(", "paramValue", "==", "null", ")", "{", "return", "null", ";", "}", "if", "(", "!", "(", "paramValue", "instanceof", "Map", ")", ")", "{", "throw", "new", "IllegalArgumentException", "(", "\"Parameter '\"", "+", "paramName", "+", "\"' must be a map: \"", "+", "paramValue", ")", ";", "}", "return", "(", "Map", "<", "String", ",", "Object", ">", ")", "paramValue", ";", "}" ]
Get the value of the given parameter name as a Map. If no such parameter name is known, null is returned. If the parameter is defined but is not a Map, an IllegalArgumentException is thrown. @param paramName Name of parameter to get value of. @return Parameter value as a String/Objec Map or null if unknown.
[ "Get", "the", "value", "of", "the", "given", "parameter", "name", "as", "a", "Map", ".", "If", "no", "such", "parameter", "name", "is", "known", "null", "is", "returned", ".", "If", "the", "parameter", "is", "defined", "but", "is", "not", "a", "Map", "an", "IllegalArgumentException", "is", "thrown", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/Service.java#L363-L373
138,040
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/Service.java
Service.setState
private void setState(State newState) { m_logger.debug("Entering state: {}", newState.toString()); synchronized (m_stateChangeLock) { m_state = newState; m_stateChangeLock.notifyAll(); } }
java
private void setState(State newState) { m_logger.debug("Entering state: {}", newState.toString()); synchronized (m_stateChangeLock) { m_state = newState; m_stateChangeLock.notifyAll(); } }
[ "private", "void", "setState", "(", "State", "newState", ")", "{", "m_logger", ".", "debug", "(", "\"Entering state: {}\"", ",", "newState", ".", "toString", "(", ")", ")", ";", "synchronized", "(", "m_stateChangeLock", ")", "{", "m_state", "=", "newState", ";", "m_stateChangeLock", ".", "notifyAll", "(", ")", ";", "}", "}" ]
Set the service's state and log the change. Notify all waiters of state change.
[ "Set", "the", "service", "s", "state", "and", "log", "the", "change", ".", "Notify", "all", "waiters", "of", "state", "change", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/Service.java#L434-L440
138,041
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/rest/RESTService.java
RESTService.startService
@Override public void startService() { m_cmdRegistry.freezeCommandSet(true); displayCommandSet(); if (m_webservice != null) { try { m_webservice.start(); } catch (Exception e) { throw new RuntimeException("Failed to start WebService", e); } } }
java
@Override public void startService() { m_cmdRegistry.freezeCommandSet(true); displayCommandSet(); if (m_webservice != null) { try { m_webservice.start(); } catch (Exception e) { throw new RuntimeException("Failed to start WebService", e); } } }
[ "@", "Override", "public", "void", "startService", "(", ")", "{", "m_cmdRegistry", ".", "freezeCommandSet", "(", "true", ")", ";", "displayCommandSet", "(", ")", ";", "if", "(", "m_webservice", "!=", "null", ")", "{", "try", "{", "m_webservice", ".", "start", "(", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Failed to start WebService\"", ",", "e", ")", ";", "}", "}", "}" ]
Begin servicing REST requests.
[ "Begin", "servicing", "REST", "requests", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/rest/RESTService.java#L75-L86
138,042
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/rest/RESTService.java
RESTService.stopService
@Override public void stopService() { try { if (m_webservice != null) { m_webservice.stop(); } } catch (Exception e) { m_logger.warn("WebService stop failed", e); } }
java
@Override public void stopService() { try { if (m_webservice != null) { m_webservice.stop(); } } catch (Exception e) { m_logger.warn("WebService stop failed", e); } }
[ "@", "Override", "public", "void", "stopService", "(", ")", "{", "try", "{", "if", "(", "m_webservice", "!=", "null", ")", "{", "m_webservice", ".", "stop", "(", ")", ";", "}", "}", "catch", "(", "Exception", "e", ")", "{", "m_logger", ".", "warn", "(", "\"WebService stop failed\"", ",", "e", ")", ";", "}", "}" ]
Shutdown the REST Service
[ "Shutdown", "the", "REST", "Service" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/rest/RESTService.java#L89-L98
138,043
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/rest/RESTService.java
RESTService.loadWebServer
private WebServer loadWebServer() { WebServer webServer = null; if (!Utils.isEmpty(getParamString("webserver_class"))) { try { Class<?> serviceClass = Class.forName(getParamString("webserver_class")); Method instanceMethod = serviceClass.getMethod("instance", (Class<?>[])null); webServer = (WebServer)instanceMethod.invoke(null, (Object[])null); webServer.init(RESTServlet.class.getName()); } catch (Exception e) { throw new RuntimeException("Error initializing WebServer: " + getParamString("webserver_class"), e); } } return webServer; }
java
private WebServer loadWebServer() { WebServer webServer = null; if (!Utils.isEmpty(getParamString("webserver_class"))) { try { Class<?> serviceClass = Class.forName(getParamString("webserver_class")); Method instanceMethod = serviceClass.getMethod("instance", (Class<?>[])null); webServer = (WebServer)instanceMethod.invoke(null, (Object[])null); webServer.init(RESTServlet.class.getName()); } catch (Exception e) { throw new RuntimeException("Error initializing WebServer: " + getParamString("webserver_class"), e); } } return webServer; }
[ "private", "WebServer", "loadWebServer", "(", ")", "{", "WebServer", "webServer", "=", "null", ";", "if", "(", "!", "Utils", ".", "isEmpty", "(", "getParamString", "(", "\"webserver_class\"", ")", ")", ")", "{", "try", "{", "Class", "<", "?", ">", "serviceClass", "=", "Class", ".", "forName", "(", "getParamString", "(", "\"webserver_class\"", ")", ")", ";", "Method", "instanceMethod", "=", "serviceClass", ".", "getMethod", "(", "\"instance\"", ",", "(", "Class", "<", "?", ">", "[", "]", ")", "null", ")", ";", "webServer", "=", "(", "WebServer", ")", "instanceMethod", ".", "invoke", "(", "null", ",", "(", "Object", "[", "]", ")", "null", ")", ";", "webServer", ".", "init", "(", "RESTServlet", ".", "class", ".", "getName", "(", ")", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Error initializing WebServer: \"", "+", "getParamString", "(", "\"webserver_class\"", ")", ",", "e", ")", ";", "}", "}", "return", "webServer", ";", "}" ]
Attempt to load the WebServer instance defined by webserver_class.
[ "Attempt", "to", "load", "the", "WebServer", "instance", "defined", "by", "webserver_class", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/rest/RESTService.java#L242-L255
138,044
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/rest/RESTService.java
RESTService.displayCommandSet
private void displayCommandSet() { if (m_logger.isDebugEnabled()) { m_logger.debug("Registered REST Commands:"); Collection<String> commands = m_cmdRegistry.getCommands(); for (String command : commands) { m_logger.debug(command); } } }
java
private void displayCommandSet() { if (m_logger.isDebugEnabled()) { m_logger.debug("Registered REST Commands:"); Collection<String> commands = m_cmdRegistry.getCommands(); for (String command : commands) { m_logger.debug(command); } } }
[ "private", "void", "displayCommandSet", "(", ")", "{", "if", "(", "m_logger", ".", "isDebugEnabled", "(", ")", ")", "{", "m_logger", ".", "debug", "(", "\"Registered REST Commands:\"", ")", ";", "Collection", "<", "String", ">", "commands", "=", "m_cmdRegistry", ".", "getCommands", "(", ")", ";", "for", "(", "String", "command", ":", "commands", ")", "{", "m_logger", ".", "debug", "(", "command", ")", ";", "}", "}", "}" ]
If DEBUG logging is enabled, log all REST commands in sorted order.
[ "If", "DEBUG", "logging", "is", "enabled", "log", "all", "REST", "commands", "in", "sorted", "order", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/rest/RESTService.java#L258-L266
138,045
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/ObjectResult.java
ObjectResult.newErrorResult
public static ObjectResult newErrorResult(String errMsg, String objID) { ObjectResult result = new ObjectResult(); result.setStatus(Status.ERROR); result.setErrorMessage(errMsg); if (!Utils.isEmpty(objID)) { result.setObjectID(objID); } return result; }
java
public static ObjectResult newErrorResult(String errMsg, String objID) { ObjectResult result = new ObjectResult(); result.setStatus(Status.ERROR); result.setErrorMessage(errMsg); if (!Utils.isEmpty(objID)) { result.setObjectID(objID); } return result; }
[ "public", "static", "ObjectResult", "newErrorResult", "(", "String", "errMsg", ",", "String", "objID", ")", "{", "ObjectResult", "result", "=", "new", "ObjectResult", "(", ")", ";", "result", ".", "setStatus", "(", "Status", ".", "ERROR", ")", ";", "result", ".", "setErrorMessage", "(", "errMsg", ")", ";", "if", "(", "!", "Utils", ".", "isEmpty", "(", "objID", ")", ")", "{", "result", ".", "setObjectID", "(", "objID", ")", ";", "}", "return", "result", ";", "}" ]
Create an ObjectResult with a status of ERROR and the given error message and optional object ID. @param errMsg Error message. @param objID Optional object ID. @return {@link ObjectResult} with an error status and message.
[ "Create", "an", "ObjectResult", "with", "a", "status", "of", "ERROR", "and", "the", "given", "error", "message", "and", "optional", "object", "ID", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/ObjectResult.java#L50-L58
138,046
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/ObjectResult.java
ObjectResult.getErrorDetails
public Map<String, String> getErrorDetails() { // Add stacktrace and/or comment fields. Map<String, String> detailMap = new LinkedHashMap<String, String>(); if (m_resultFields.containsKey(COMMENT)) { detailMap.put(COMMENT, m_resultFields.get(COMMENT)); } if (m_resultFields.containsKey(STACK_TRACE)) { detailMap.put(STACK_TRACE, m_resultFields.get(STACK_TRACE)); } return detailMap; }
java
public Map<String, String> getErrorDetails() { // Add stacktrace and/or comment fields. Map<String, String> detailMap = new LinkedHashMap<String, String>(); if (m_resultFields.containsKey(COMMENT)) { detailMap.put(COMMENT, m_resultFields.get(COMMENT)); } if (m_resultFields.containsKey(STACK_TRACE)) { detailMap.put(STACK_TRACE, m_resultFields.get(STACK_TRACE)); } return detailMap; }
[ "public", "Map", "<", "String", ",", "String", ">", "getErrorDetails", "(", ")", "{", "// Add stacktrace and/or comment fields.\r", "Map", "<", "String", ",", "String", ">", "detailMap", "=", "new", "LinkedHashMap", "<", "String", ",", "String", ">", "(", ")", ";", "if", "(", "m_resultFields", ".", "containsKey", "(", "COMMENT", ")", ")", "{", "detailMap", ".", "put", "(", "COMMENT", ",", "m_resultFields", ".", "get", "(", "COMMENT", ")", ")", ";", "}", "if", "(", "m_resultFields", ".", "containsKey", "(", "STACK_TRACE", ")", ")", "{", "detailMap", ".", "put", "(", "STACK_TRACE", ",", "m_resultFields", ".", "get", "(", "STACK_TRACE", ")", ")", ";", "}", "return", "detailMap", ";", "}" ]
Get the error details for this response object, if any exists. The error details is typically a stack trace or comment message. The details are returned as a map of detail names to values. @return Map of error detail names to values, if any. If there are no details, the map will be empty (not null).
[ "Get", "the", "error", "details", "for", "this", "response", "object", "if", "any", "exists", ".", "The", "error", "details", "is", "typically", "a", "stack", "trace", "or", "comment", "message", ".", "The", "details", "are", "returned", "as", "a", "map", "of", "detail", "names", "to", "values", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/ObjectResult.java#L143-L153
138,047
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/ObjectResult.java
ObjectResult.getStatus
public Status getStatus() { String status = m_resultFields.get(STATUS); if (status == null) { return Status.OK; } else { return Status.valueOf(status.toUpperCase()); } }
java
public Status getStatus() { String status = m_resultFields.get(STATUS); if (status == null) { return Status.OK; } else { return Status.valueOf(status.toUpperCase()); } }
[ "public", "Status", "getStatus", "(", ")", "{", "String", "status", "=", "m_resultFields", ".", "get", "(", "STATUS", ")", ";", "if", "(", "status", "==", "null", ")", "{", "return", "Status", ".", "OK", ";", "}", "else", "{", "return", "Status", ".", "valueOf", "(", "status", ".", "toUpperCase", "(", ")", ")", ";", "}", "}" ]
Get the status for this object update result. If a status has not been explicitly defined, a value of OK is returned. @return Status value of this object update result.
[ "Get", "the", "status", "for", "this", "object", "update", "result", ".", "If", "a", "status", "has", "not", "been", "explicitly", "defined", "a", "value", "of", "OK", "is", "returned", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/ObjectResult.java#L170-L177
138,048
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/ObjectResult.java
ObjectResult.toDoc
public UNode toDoc() { // Root node is called "doc". UNode result = UNode.createMapNode("doc"); // Each child of "doc" is a simple VALUE node. for (String fieldName : m_resultFields.keySet()) { // In XML, we want the element name to be "field" when the node name is "_ID". if (fieldName.equals(OBJECT_ID)) { result.addValueNode(fieldName, m_resultFields.get(fieldName), "field"); } else { result.addValueNode(fieldName, m_resultFields.get(fieldName)); } } return result; }
java
public UNode toDoc() { // Root node is called "doc". UNode result = UNode.createMapNode("doc"); // Each child of "doc" is a simple VALUE node. for (String fieldName : m_resultFields.keySet()) { // In XML, we want the element name to be "field" when the node name is "_ID". if (fieldName.equals(OBJECT_ID)) { result.addValueNode(fieldName, m_resultFields.get(fieldName), "field"); } else { result.addValueNode(fieldName, m_resultFields.get(fieldName)); } } return result; }
[ "public", "UNode", "toDoc", "(", ")", "{", "// Root node is called \"doc\".\r", "UNode", "result", "=", "UNode", ".", "createMapNode", "(", "\"doc\"", ")", ";", "// Each child of \"doc\" is a simple VALUE node.\r", "for", "(", "String", "fieldName", ":", "m_resultFields", ".", "keySet", "(", ")", ")", "{", "// In XML, we want the element name to be \"field\" when the node name is \"_ID\".\r", "if", "(", "fieldName", ".", "equals", "(", "OBJECT_ID", ")", ")", "{", "result", ".", "addValueNode", "(", "fieldName", ",", "m_resultFields", ".", "get", "(", "fieldName", ")", ",", "\"field\"", ")", ";", "}", "else", "{", "result", ".", "addValueNode", "(", "fieldName", ",", "m_resultFields", ".", "get", "(", "fieldName", ")", ")", ";", "}", "}", "return", "result", ";", "}" ]
Serialize this ObjectResult into a UNode tree. The root node is called "doc". @return This object serialized into a UNode tree.
[ "Serialize", "this", "ObjectResult", "into", "a", "UNode", "tree", ".", "The", "root", "node", "is", "called", "doc", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/ObjectResult.java#L198-L212
138,049
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/search/aggregate/DBEntitySequenceFactory.java
DBEntitySequenceFactory.collectUninitializedEntities
private List<DBEntity> collectUninitializedEntities(DBEntity entity, final String category, final TableDefinition tableDef, final List<String> fields, final String link, final Map<ObjectID, LinkList> cache, final Set<ObjectID> keys, final DBEntitySequenceOptions options) { DBEntityCollector collector = new DBEntityCollector(entity) { @Override protected boolean visit(DBEntity entity, List<DBEntity> list){ if (entity.findIterator(category) == null) { ObjectID id = entity.id(); LinkList columns = cache.get(id); if (columns == null) { keys.add(id); list.add(entity); return (keys.size() < options.initialLinkBufferDimension); } DBLinkIterator linkIterator = new DBLinkIterator(entity, link, columns, m_options.linkBuffer, DBEntitySequenceFactory.this, category); entity.addIterator(category, new DBEntityIterator(tableDef, entity, linkIterator, fields, DBEntitySequenceFactory.this, category, m_options)); } return true; } }; return collector.collect(); }
java
private List<DBEntity> collectUninitializedEntities(DBEntity entity, final String category, final TableDefinition tableDef, final List<String> fields, final String link, final Map<ObjectID, LinkList> cache, final Set<ObjectID> keys, final DBEntitySequenceOptions options) { DBEntityCollector collector = new DBEntityCollector(entity) { @Override protected boolean visit(DBEntity entity, List<DBEntity> list){ if (entity.findIterator(category) == null) { ObjectID id = entity.id(); LinkList columns = cache.get(id); if (columns == null) { keys.add(id); list.add(entity); return (keys.size() < options.initialLinkBufferDimension); } DBLinkIterator linkIterator = new DBLinkIterator(entity, link, columns, m_options.linkBuffer, DBEntitySequenceFactory.this, category); entity.addIterator(category, new DBEntityIterator(tableDef, entity, linkIterator, fields, DBEntitySequenceFactory.this, category, m_options)); } return true; } }; return collector.collect(); }
[ "private", "List", "<", "DBEntity", ">", "collectUninitializedEntities", "(", "DBEntity", "entity", ",", "final", "String", "category", ",", "final", "TableDefinition", "tableDef", ",", "final", "List", "<", "String", ">", "fields", ",", "final", "String", "link", ",", "final", "Map", "<", "ObjectID", ",", "LinkList", ">", "cache", ",", "final", "Set", "<", "ObjectID", ">", "keys", ",", "final", "DBEntitySequenceOptions", "options", ")", "{", "DBEntityCollector", "collector", "=", "new", "DBEntityCollector", "(", "entity", ")", "{", "@", "Override", "protected", "boolean", "visit", "(", "DBEntity", "entity", ",", "List", "<", "DBEntity", ">", "list", ")", "{", "if", "(", "entity", ".", "findIterator", "(", "category", ")", "==", "null", ")", "{", "ObjectID", "id", "=", "entity", ".", "id", "(", ")", ";", "LinkList", "columns", "=", "cache", ".", "get", "(", "id", ")", ";", "if", "(", "columns", "==", "null", ")", "{", "keys", ".", "add", "(", "id", ")", ";", "list", ".", "add", "(", "entity", ")", ";", "return", "(", "keys", ".", "size", "(", ")", "<", "options", ".", "initialLinkBufferDimension", ")", ";", "}", "DBLinkIterator", "linkIterator", "=", "new", "DBLinkIterator", "(", "entity", ",", "link", ",", "columns", ",", "m_options", ".", "linkBuffer", ",", "DBEntitySequenceFactory", ".", "this", ",", "category", ")", ";", "entity", ".", "addIterator", "(", "category", ",", "new", "DBEntityIterator", "(", "tableDef", ",", "entity", ",", "linkIterator", ",", "fields", ",", "DBEntitySequenceFactory", ".", "this", ",", "category", ",", "m_options", ")", ")", ";", "}", "return", "true", ";", "}", "}", ";", "return", "collector", ".", "collect", "(", ")", ";", "}" ]
Collects the entities to be initialized with the initial list of links using the link list bulk fetch. Visits all the entities buffered by the iterators of the same category. @param entity next entity to be returned by the iterator (must be initialized first) @param category the iterator category that will return the linked entities @param tableDef type of the linked entities @param fields scalar fields to be fetched by the linked entities iterators @param link link name @param cache link list cache. If the cache contains the requested link list, the visited entity is initialized with the cached list and skipped @param keys set of 'rows' to be fetched. The set will be filled by this method @param options limits the number of rows to be fetched @return list of entities to be initialized. The set of physical rows to be fetched is returned in the 'keys' set. The set size can less than the list size if the list contains duplicates
[ "Collects", "the", "entities", "to", "be", "initialized", "with", "the", "initial", "list", "of", "links", "using", "the", "link", "list", "bulk", "fetch", ".", "Visits", "all", "the", "entities", "buffered", "by", "the", "iterators", "of", "the", "same", "category", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/search/aggregate/DBEntitySequenceFactory.java#L315-L338
138,050
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/search/aggregate/DBEntitySequenceFactory.java
DBEntitySequenceFactory.getCache
private <C, K, T> LRUCache<K, T> getCache(Map<C, LRUCache<K, T>> cacheMap, int capacity, C category) { LRUCache<K, T> cache = cacheMap.get(category); if (cache == null) { cache = new LRUCache<K, T>(capacity); cacheMap.put(category, cache); } return cache; }
java
private <C, K, T> LRUCache<K, T> getCache(Map<C, LRUCache<K, T>> cacheMap, int capacity, C category) { LRUCache<K, T> cache = cacheMap.get(category); if (cache == null) { cache = new LRUCache<K, T>(capacity); cacheMap.put(category, cache); } return cache; }
[ "private", "<", "C", ",", "K", ",", "T", ">", "LRUCache", "<", "K", ",", "T", ">", "getCache", "(", "Map", "<", "C", ",", "LRUCache", "<", "K", ",", "T", ">", ">", "cacheMap", ",", "int", "capacity", ",", "C", "category", ")", "{", "LRUCache", "<", "K", ",", "T", ">", "cache", "=", "cacheMap", ".", "get", "(", "category", ")", ";", "if", "(", "cache", "==", "null", ")", "{", "cache", "=", "new", "LRUCache", "<", "K", ",", "T", ">", "(", "capacity", ")", ";", "cacheMap", ".", "put", "(", "category", ",", "cache", ")", ";", "}", "return", "cache", ";", "}" ]
Returns the LRU cache of the specified 'iterator', 'entity' or 'continuationlink' category. @param cacheMap either {@link #m_linkCache} or {@link #m_scalarCache} @param category 'iterator' category (for instance, 'Person.Message.Sender') in case of {@link #m_linkCache} 'entity' category (for instance, 'Person[Name,Department]') in case of {@link #m_scalarCache} 'continuationlink' category (for instance, 'Person.Message') in case of {@link #m_continuationlinkCache} @return LRUCache<ObjectID, LinkList> cache in case of {@link #m_linkCache} LRUCache<String, Map<String, String>> cache in case of {@link #m_scalarCache} LRUCache<String, LinkList> cache in case of {@link #m_continuationlinkCache}
[ "Returns", "the", "LRU", "cache", "of", "the", "specified", "iterator", "entity", "or", "continuationlink", "category", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/search/aggregate/DBEntitySequenceFactory.java#L382-L389
138,051
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/search/aggregate/DBEntitySequenceFactory.java
DBEntitySequenceFactory.fetchScalarFields
private Map<ObjectID, Map<String, String>> fetchScalarFields(TableDefinition tableDef, Collection<ObjectID> ids, List<String> fields, String category) { timers.start(category, "Init Fields"); Map<ObjectID, Map<String, String>> map = SpiderHelper.getScalarValues(tableDef, ids, fields); long time = timers.stop(category, "Init Fields", ids.size()); log.debug("fetch {} {} ({})", new Object[] {ids.size(), category, Timer.toString(time)}); return map; }
java
private Map<ObjectID, Map<String, String>> fetchScalarFields(TableDefinition tableDef, Collection<ObjectID> ids, List<String> fields, String category) { timers.start(category, "Init Fields"); Map<ObjectID, Map<String, String>> map = SpiderHelper.getScalarValues(tableDef, ids, fields); long time = timers.stop(category, "Init Fields", ids.size()); log.debug("fetch {} {} ({})", new Object[] {ids.size(), category, Timer.toString(time)}); return map; }
[ "private", "Map", "<", "ObjectID", ",", "Map", "<", "String", ",", "String", ">", ">", "fetchScalarFields", "(", "TableDefinition", "tableDef", ",", "Collection", "<", "ObjectID", ">", "ids", ",", "List", "<", "String", ">", "fields", ",", "String", "category", ")", "{", "timers", ".", "start", "(", "category", ",", "\"Init Fields\"", ")", ";", "Map", "<", "ObjectID", ",", "Map", "<", "String", ",", "String", ">", ">", "map", "=", "SpiderHelper", ".", "getScalarValues", "(", "tableDef", ",", "ids", ",", "fields", ")", ";", "long", "time", "=", "timers", ".", "stop", "(", "category", ",", "\"Init Fields\"", ",", "ids", ".", "size", "(", ")", ")", ";", "log", ".", "debug", "(", "\"fetch {} {} ({})\"", ",", "new", "Object", "[", "]", "{", "ids", ".", "size", "(", ")", ",", "category", ",", "Timer", ".", "toString", "(", "time", ")", "}", ")", ";", "return", "map", ";", "}" ]
Fetches the scalar field values of the specified set of entities @param tableDef entity type @param keys entity id list @param scalarFields field name list @return result of {@link #multiget_slice(List, ColumnParent, SlicePredicate)} execution
[ "Fetches", "the", "scalar", "field", "values", "of", "the", "specified", "set", "of", "entities" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/search/aggregate/DBEntitySequenceFactory.java#L421-L428
138,052
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/search/aggregate/DBEntitySequenceFactory.java
DBEntitySequenceFactory.fetchLinks
List<ObjectID> fetchLinks(TableDefinition tableDef, ObjectID id, String link, ObjectID continuationLink, int count, String category) { timers.start(category+" links", "Continuation"); FieldDefinition linkField = tableDef.getFieldDef(link); List<ObjectID> list = SpiderHelper.getLinks(linkField, id, continuationLink, true, count); int resultCount = (continuationLink == null) ? list.size() : list.size() - 1; long time = timers.stop(category + " links", "Continuation", resultCount); log.debug("fetch {} {} continuation links ({})", new Object[]{resultCount, category, Timer.toString(time)}); return list; }
java
List<ObjectID> fetchLinks(TableDefinition tableDef, ObjectID id, String link, ObjectID continuationLink, int count, String category) { timers.start(category+" links", "Continuation"); FieldDefinition linkField = tableDef.getFieldDef(link); List<ObjectID> list = SpiderHelper.getLinks(linkField, id, continuationLink, true, count); int resultCount = (continuationLink == null) ? list.size() : list.size() - 1; long time = timers.stop(category + " links", "Continuation", resultCount); log.debug("fetch {} {} continuation links ({})", new Object[]{resultCount, category, Timer.toString(time)}); return list; }
[ "List", "<", "ObjectID", ">", "fetchLinks", "(", "TableDefinition", "tableDef", ",", "ObjectID", "id", ",", "String", "link", ",", "ObjectID", "continuationLink", ",", "int", "count", ",", "String", "category", ")", "{", "timers", ".", "start", "(", "category", "+", "\" links\"", ",", "\"Continuation\"", ")", ";", "FieldDefinition", "linkField", "=", "tableDef", ".", "getFieldDef", "(", "link", ")", ";", "List", "<", "ObjectID", ">", "list", "=", "SpiderHelper", ".", "getLinks", "(", "linkField", ",", "id", ",", "continuationLink", ",", "true", ",", "count", ")", ";", "int", "resultCount", "=", "(", "continuationLink", "==", "null", ")", "?", "list", ".", "size", "(", ")", ":", "list", ".", "size", "(", ")", "-", "1", ";", "long", "time", "=", "timers", ".", "stop", "(", "category", "+", "\" links\"", ",", "\"Continuation\"", ",", "resultCount", ")", ";", "log", ".", "debug", "(", "\"fetch {} {} continuation links ({})\"", ",", "new", "Object", "[", "]", "{", "resultCount", ",", "category", ",", "Timer", ".", "toString", "(", "time", ")", "}", ")", ";", "return", "list", ";", "}" ]
Fetches the link list of the specified 'iterator' category of the specified entity @param tableDef entity type @param id entity id @param link link name @param continuationLink last fetched link or null if it is the initial fetch. @param count maximum size of the link list to be fetched @param category category of the iterators that will iterate the linked entities. @return result of {@link #get_slice(ByteBuffer, ColumnParent, SlicePredicate)} execution
[ "Fetches", "the", "link", "list", "of", "the", "specified", "iterator", "category", "of", "the", "specified", "entity" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/search/aggregate/DBEntitySequenceFactory.java#L450-L459
138,053
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/search/aggregate/DBEntitySequenceFactory.java
DBEntitySequenceFactory.fetchLinks
private Map<ObjectID, List<ObjectID>> fetchLinks(TableDefinition tableDef, Collection<ObjectID> ids, String link, int count) { FieldDefinition linkField = tableDef.getFieldDef(link); return SpiderHelper.getLinks(linkField, ids, null, true, count); }
java
private Map<ObjectID, List<ObjectID>> fetchLinks(TableDefinition tableDef, Collection<ObjectID> ids, String link, int count) { FieldDefinition linkField = tableDef.getFieldDef(link); return SpiderHelper.getLinks(linkField, ids, null, true, count); }
[ "private", "Map", "<", "ObjectID", ",", "List", "<", "ObjectID", ">", ">", "fetchLinks", "(", "TableDefinition", "tableDef", ",", "Collection", "<", "ObjectID", ">", "ids", ",", "String", "link", ",", "int", "count", ")", "{", "FieldDefinition", "linkField", "=", "tableDef", ".", "getFieldDef", "(", "link", ")", ";", "return", "SpiderHelper", ".", "getLinks", "(", "linkField", ",", "ids", ",", "null", ",", "true", ",", "count", ")", ";", "}" ]
Fetches first N links of the specified type for every specified entity. @param tableDef entity type @param keys entity id list @param link link name @param count maximum size of the link list to be fetched for every entity @return result of {@link #multiget_slice(List, ColumnParent, SlicePredicate)} execution
[ "Fetches", "first", "N", "links", "of", "the", "specified", "type", "for", "every", "specified", "entity", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/search/aggregate/DBEntitySequenceFactory.java#L470-L474
138,054
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/JSONEmitter.java
JSONEmitter.addValue
public JSONEmitter addValue(String value) { checkComma(); write('"'); write(encodeString(value)); write('"'); return this; }
java
public JSONEmitter addValue(String value) { checkComma(); write('"'); write(encodeString(value)); write('"'); return this; }
[ "public", "JSONEmitter", "addValue", "(", "String", "value", ")", "{", "checkComma", "(", ")", ";", "write", "(", "'", "'", ")", ";", "write", "(", "encodeString", "(", "value", ")", ")", ";", "write", "(", "'", "'", ")", ";", "return", "this", ";", "}" ]
Add a String value. @param value String value. @return The same JSONEmitter object, which allows call chaining.
[ "Add", "a", "String", "value", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/JSONEmitter.java#L251-L257
138,055
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/JSONEmitter.java
JSONEmitter.write
private void write(String str) { try { m_writer.write(str); } catch (IOException ex) { throw new RuntimeException(ex); } }
java
private void write(String str) { try { m_writer.write(str); } catch (IOException ex) { throw new RuntimeException(ex); } }
[ "private", "void", "write", "(", "String", "str", ")", "{", "try", "{", "m_writer", ".", "write", "(", "str", ")", ";", "}", "catch", "(", "IOException", "ex", ")", "{", "throw", "new", "RuntimeException", "(", "ex", ")", ";", "}", "}" ]
Write a string and turn any IOException caught into a RuntimeException
[ "Write", "a", "string", "and", "turn", "any", "IOException", "caught", "into", "a", "RuntimeException" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/JSONEmitter.java#L351-L357
138,056
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/DBTransaction.java
DBTransaction.getColumnUpdatesMap
public Map<String, Map<String, List<DColumn>>> getColumnUpdatesMap() { Map<String, Map<String, List<DColumn>>> storeMap = new HashMap<>(); for(ColumnUpdate mutation: getColumnUpdates()) { String storeName = mutation.getStoreName(); String rowKey = mutation.getRowKey(); DColumn column = mutation.getColumn(); Map<String, List<DColumn>> rowMap = storeMap.get(storeName); if(rowMap == null) { rowMap = new HashMap<>(); storeMap.put(storeName, rowMap); } List<DColumn> columnsList = rowMap.get(rowKey); if(columnsList == null) { columnsList = new ArrayList<>(); rowMap.put(rowKey, columnsList); } columnsList.add(column); } return storeMap; }
java
public Map<String, Map<String, List<DColumn>>> getColumnUpdatesMap() { Map<String, Map<String, List<DColumn>>> storeMap = new HashMap<>(); for(ColumnUpdate mutation: getColumnUpdates()) { String storeName = mutation.getStoreName(); String rowKey = mutation.getRowKey(); DColumn column = mutation.getColumn(); Map<String, List<DColumn>> rowMap = storeMap.get(storeName); if(rowMap == null) { rowMap = new HashMap<>(); storeMap.put(storeName, rowMap); } List<DColumn> columnsList = rowMap.get(rowKey); if(columnsList == null) { columnsList = new ArrayList<>(); rowMap.put(rowKey, columnsList); } columnsList.add(column); } return storeMap; }
[ "public", "Map", "<", "String", ",", "Map", "<", "String", ",", "List", "<", "DColumn", ">", ">", ">", "getColumnUpdatesMap", "(", ")", "{", "Map", "<", "String", ",", "Map", "<", "String", ",", "List", "<", "DColumn", ">", ">", ">", "storeMap", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "ColumnUpdate", "mutation", ":", "getColumnUpdates", "(", ")", ")", "{", "String", "storeName", "=", "mutation", ".", "getStoreName", "(", ")", ";", "String", "rowKey", "=", "mutation", ".", "getRowKey", "(", ")", ";", "DColumn", "column", "=", "mutation", ".", "getColumn", "(", ")", ";", "Map", "<", "String", ",", "List", "<", "DColumn", ">", ">", "rowMap", "=", "storeMap", ".", "get", "(", "storeName", ")", ";", "if", "(", "rowMap", "==", "null", ")", "{", "rowMap", "=", "new", "HashMap", "<>", "(", ")", ";", "storeMap", ".", "put", "(", "storeName", ",", "rowMap", ")", ";", "}", "List", "<", "DColumn", ">", "columnsList", "=", "rowMap", ".", "get", "(", "rowKey", ")", ";", "if", "(", "columnsList", "==", "null", ")", "{", "columnsList", "=", "new", "ArrayList", "<>", "(", ")", ";", "rowMap", ".", "put", "(", "rowKey", ",", "columnsList", ")", ";", "}", "columnsList", ".", "add", "(", "column", ")", ";", "}", "return", "storeMap", ";", "}" ]
Get the map of the column updates as storeName -> rowKey -> list of DColumns
[ "Get", "the", "map", "of", "the", "column", "updates", "as", "storeName", "-", ">", "rowKey", "-", ">", "list", "of", "DColumns" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/DBTransaction.java#L109-L128
138,057
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/DBTransaction.java
DBTransaction.getColumnDeletesMap
public Map<String, Map<String, List<String>>> getColumnDeletesMap() { Map<String, Map<String, List<String>>> storeMap = new HashMap<>(); for(ColumnDelete mutation: getColumnDeletes()) { String storeName = mutation.getStoreName(); String rowKey = mutation.getRowKey(); String column = mutation.getColumnName(); Map<String, List<String>> rowMap = storeMap.get(storeName); if(rowMap == null) { rowMap = new HashMap<>(); storeMap.put(storeName, rowMap); } List<String> columnsList = rowMap.get(rowKey); if(columnsList == null) { columnsList = new ArrayList<>(); rowMap.put(rowKey, columnsList); } columnsList.add(column); } return storeMap; }
java
public Map<String, Map<String, List<String>>> getColumnDeletesMap() { Map<String, Map<String, List<String>>> storeMap = new HashMap<>(); for(ColumnDelete mutation: getColumnDeletes()) { String storeName = mutation.getStoreName(); String rowKey = mutation.getRowKey(); String column = mutation.getColumnName(); Map<String, List<String>> rowMap = storeMap.get(storeName); if(rowMap == null) { rowMap = new HashMap<>(); storeMap.put(storeName, rowMap); } List<String> columnsList = rowMap.get(rowKey); if(columnsList == null) { columnsList = new ArrayList<>(); rowMap.put(rowKey, columnsList); } columnsList.add(column); } return storeMap; }
[ "public", "Map", "<", "String", ",", "Map", "<", "String", ",", "List", "<", "String", ">", ">", ">", "getColumnDeletesMap", "(", ")", "{", "Map", "<", "String", ",", "Map", "<", "String", ",", "List", "<", "String", ">", ">", ">", "storeMap", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "ColumnDelete", "mutation", ":", "getColumnDeletes", "(", ")", ")", "{", "String", "storeName", "=", "mutation", ".", "getStoreName", "(", ")", ";", "String", "rowKey", "=", "mutation", ".", "getRowKey", "(", ")", ";", "String", "column", "=", "mutation", ".", "getColumnName", "(", ")", ";", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "rowMap", "=", "storeMap", ".", "get", "(", "storeName", ")", ";", "if", "(", "rowMap", "==", "null", ")", "{", "rowMap", "=", "new", "HashMap", "<>", "(", ")", ";", "storeMap", ".", "put", "(", "storeName", ",", "rowMap", ")", ";", "}", "List", "<", "String", ">", "columnsList", "=", "rowMap", ".", "get", "(", "rowKey", ")", ";", "if", "(", "columnsList", "==", "null", ")", "{", "columnsList", "=", "new", "ArrayList", "<>", "(", ")", ";", "rowMap", ".", "put", "(", "rowKey", ",", "columnsList", ")", ";", "}", "columnsList", ".", "add", "(", "column", ")", ";", "}", "return", "storeMap", ";", "}" ]
Get the map of the column deletes as storeName -> rowKey -> list of column names
[ "Get", "the", "map", "of", "the", "column", "deletes", "as", "storeName", "-", ">", "rowKey", "-", ">", "list", "of", "column", "names" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/DBTransaction.java#L133-L152
138,058
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/DBTransaction.java
DBTransaction.getRowDeletesMap
public Map<String, List<String>> getRowDeletesMap() { Map<String, List<String>> storeMap = new HashMap<>(); for(RowDelete mutation: getRowDeletes()) { String storeName = mutation.getStoreName(); String rowKey = mutation.getRowKey(); List<String> rowList = storeMap.get(storeName); if(rowList == null) { rowList = new ArrayList<>(); storeMap.put(storeName, rowList); } rowList.add(rowKey); } return storeMap; }
java
public Map<String, List<String>> getRowDeletesMap() { Map<String, List<String>> storeMap = new HashMap<>(); for(RowDelete mutation: getRowDeletes()) { String storeName = mutation.getStoreName(); String rowKey = mutation.getRowKey(); List<String> rowList = storeMap.get(storeName); if(rowList == null) { rowList = new ArrayList<>(); storeMap.put(storeName, rowList); } rowList.add(rowKey); } return storeMap; }
[ "public", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "getRowDeletesMap", "(", ")", "{", "Map", "<", "String", ",", "List", "<", "String", ">", ">", "storeMap", "=", "new", "HashMap", "<>", "(", ")", ";", "for", "(", "RowDelete", "mutation", ":", "getRowDeletes", "(", ")", ")", "{", "String", "storeName", "=", "mutation", ".", "getStoreName", "(", ")", ";", "String", "rowKey", "=", "mutation", ".", "getRowKey", "(", ")", ";", "List", "<", "String", ">", "rowList", "=", "storeMap", ".", "get", "(", "storeName", ")", ";", "if", "(", "rowList", "==", "null", ")", "{", "rowList", "=", "new", "ArrayList", "<>", "(", ")", ";", "storeMap", ".", "put", "(", "storeName", ",", "rowList", ")", ";", "}", "rowList", ".", "add", "(", "rowKey", ")", ";", "}", "return", "storeMap", ";", "}" ]
Get the map of the row deletes as storeName -> list of row keys
[ "Get", "the", "map", "of", "the", "row", "deletes", "as", "storeName", "-", ">", "list", "of", "row", "keys" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/DBTransaction.java#L157-L170
138,059
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/DBTransaction.java
DBTransaction.addColumn
public void addColumn(String storeName, String rowKey, String columnName, byte[] columnValue) { m_columnUpdates.add(new ColumnUpdate(storeName, rowKey, columnName, columnValue)); }
java
public void addColumn(String storeName, String rowKey, String columnName, byte[] columnValue) { m_columnUpdates.add(new ColumnUpdate(storeName, rowKey, columnName, columnValue)); }
[ "public", "void", "addColumn", "(", "String", "storeName", ",", "String", "rowKey", ",", "String", "columnName", ",", "byte", "[", "]", "columnValue", ")", "{", "m_columnUpdates", ".", "add", "(", "new", "ColumnUpdate", "(", "storeName", ",", "rowKey", ",", "columnName", ",", "columnValue", ")", ")", ";", "}" ]
Add or set a column with the given binary value. @param storeName Name of store that owns row. @param rowKey Key of row that owns column. @param columnName Name of column. @param columnValue Column value in binary.
[ "Add", "or", "set", "a", "column", "with", "the", "given", "binary", "value", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/DBTransaction.java#L182-L184
138,060
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/DBTransaction.java
DBTransaction.addColumn
public void addColumn(String storeName, String rowKey, String columnName, String columnValue) { addColumn(storeName, rowKey, columnName, Utils.toBytes(columnValue)); }
java
public void addColumn(String storeName, String rowKey, String columnName, String columnValue) { addColumn(storeName, rowKey, columnName, Utils.toBytes(columnValue)); }
[ "public", "void", "addColumn", "(", "String", "storeName", ",", "String", "rowKey", ",", "String", "columnName", ",", "String", "columnValue", ")", "{", "addColumn", "(", "storeName", ",", "rowKey", ",", "columnName", ",", "Utils", ".", "toBytes", "(", "columnValue", ")", ")", ";", "}" ]
Add or set a column with the given string value. The column value is converted to binary form using UTF-8. @param storeName Name of store that owns row. @param rowKey Key of row that owns column. @param columnName Name of column. @param columnValue Column value as a string.
[ "Add", "or", "set", "a", "column", "with", "the", "given", "string", "value", ".", "The", "column", "value", "is", "converted", "to", "binary", "form", "using", "UTF", "-", "8", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/DBTransaction.java#L206-L208
138,061
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/DBTransaction.java
DBTransaction.deleteRow
public void deleteRow(String storeName, String rowKey) { m_rowDeletes.add(new RowDelete(storeName, rowKey)); }
java
public void deleteRow(String storeName, String rowKey) { m_rowDeletes.add(new RowDelete(storeName, rowKey)); }
[ "public", "void", "deleteRow", "(", "String", "storeName", ",", "String", "rowKey", ")", "{", "m_rowDeletes", ".", "add", "(", "new", "RowDelete", "(", "storeName", ",", "rowKey", ")", ")", ";", "}" ]
Add an update that will delete the row with the given row key from the given store. @param storeName Name of store from which to delete an object row. @param rowKey Row key in string form.
[ "Add", "an", "update", "that", "will", "delete", "the", "row", "with", "the", "given", "row", "key", "from", "the", "given", "store", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/DBTransaction.java#L230-L232
138,062
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/DBTransaction.java
DBTransaction.traceMutations
public void traceMutations(Logger logger) { logger.debug("Transaction in " + getTenant().getName() + ": " + getMutationsCount() + " mutations"); for(ColumnUpdate mutation: getColumnUpdates()) { logger.trace(mutation.toString()); } //2. delete columns for(ColumnDelete mutation: getColumnDeletes()) { logger.trace(mutation.toString()); } //3. delete rows for(RowDelete mutation: getRowDeletes()) { logger.trace(mutation.toString()); } }
java
public void traceMutations(Logger logger) { logger.debug("Transaction in " + getTenant().getName() + ": " + getMutationsCount() + " mutations"); for(ColumnUpdate mutation: getColumnUpdates()) { logger.trace(mutation.toString()); } //2. delete columns for(ColumnDelete mutation: getColumnDeletes()) { logger.trace(mutation.toString()); } //3. delete rows for(RowDelete mutation: getRowDeletes()) { logger.trace(mutation.toString()); } }
[ "public", "void", "traceMutations", "(", "Logger", "logger", ")", "{", "logger", ".", "debug", "(", "\"Transaction in \"", "+", "getTenant", "(", ")", ".", "getName", "(", ")", "+", "\": \"", "+", "getMutationsCount", "(", ")", "+", "\" mutations\"", ")", ";", "for", "(", "ColumnUpdate", "mutation", ":", "getColumnUpdates", "(", ")", ")", "{", "logger", ".", "trace", "(", "mutation", ".", "toString", "(", ")", ")", ";", "}", "//2. delete columns\r", "for", "(", "ColumnDelete", "mutation", ":", "getColumnDeletes", "(", ")", ")", "{", "logger", ".", "trace", "(", "mutation", ".", "toString", "(", ")", ")", ";", "}", "//3. delete rows\r", "for", "(", "RowDelete", "mutation", ":", "getRowDeletes", "(", ")", ")", "{", "logger", ".", "trace", "(", "mutation", ".", "toString", "(", ")", ")", ";", "}", "}" ]
For extreme logging. @param logger Logger to trace mutations to.
[ "For", "extreme", "logging", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/DBTransaction.java#L268-L281
138,063
QSFT/Doradus
doradus-server/src/examples/java/com/dell/doradus/service/olap/mono/OLAPMonoService.java
OLAPMonoService.addBatch
public BatchResult addBatch(ApplicationDefinition appDef, String shardName, OlapBatch batch) { Utils.require(shardName.equals(MONO_SHARD_NAME), "Shard name must be: " + MONO_SHARD_NAME); return OLAPService.instance().addBatch(appDef, shardName, batch); }
java
public BatchResult addBatch(ApplicationDefinition appDef, String shardName, OlapBatch batch) { Utils.require(shardName.equals(MONO_SHARD_NAME), "Shard name must be: " + MONO_SHARD_NAME); return OLAPService.instance().addBatch(appDef, shardName, batch); }
[ "public", "BatchResult", "addBatch", "(", "ApplicationDefinition", "appDef", ",", "String", "shardName", ",", "OlapBatch", "batch", ")", "{", "Utils", ".", "require", "(", "shardName", ".", "equals", "(", "MONO_SHARD_NAME", ")", ",", "\"Shard name must be: \"", "+", "MONO_SHARD_NAME", ")", ";", "return", "OLAPService", ".", "instance", "(", ")", ".", "addBatch", "(", "appDef", ",", "shardName", ",", "batch", ")", ";", "}" ]
Store name should always be MONO_SHARD_NAME for OLAPMono.
[ "Store", "name", "should", "always", "be", "MONO_SHARD_NAME", "for", "OLAPMono", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/examples/java/com/dell/doradus/service/olap/mono/OLAPMonoService.java#L139-L142
138,064
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/AggregateResult.java
AggregateResult.toDoc
public UNode toDoc() { // Root "results" node. UNode resultsNode = UNode.createMapNode("results"); // "aggregate" node. UNode aggNode = resultsNode.addMapNode("aggregate"); aggNode.addValueNode("metric", m_metricParam, true); if (m_queryParam != null){ aggNode.addValueNode("query", m_queryParam, true); } if (m_groupingParam != null) { aggNode.addValueNode("group", m_groupingParam, true); } // Add "totalobjects" if used. if (m_totalObjects >= 0) { resultsNode.addValueNode("totalobjects", Long.toString(m_totalObjects)); } // Add global or summary value if present. if (m_globalValue != null) { if (m_groupSetList == null) { resultsNode.addChildNode(UNode.createValueNode("value", m_globalValue)); } else { resultsNode.addChildNode(UNode.createValueNode("summary", m_globalValue)); } } // If needed, the "groupsets" node becomes the new parent. UNode parentNode = resultsNode; boolean bGroupSetsNode = false; if (m_groupSetList != null && m_groupSetList.size() > 1) { bGroupSetsNode = true; UNode groupSetsNode = parentNode.addArrayNode("groupsets"); parentNode = groupSetsNode; } // Add groupsets, if any, to the parent node. if (m_groupSetList != null) { for (AggGroupSet groupSet : m_groupSetList) { groupSet.addDoc(parentNode, bGroupSetsNode); } } return resultsNode; }
java
public UNode toDoc() { // Root "results" node. UNode resultsNode = UNode.createMapNode("results"); // "aggregate" node. UNode aggNode = resultsNode.addMapNode("aggregate"); aggNode.addValueNode("metric", m_metricParam, true); if (m_queryParam != null){ aggNode.addValueNode("query", m_queryParam, true); } if (m_groupingParam != null) { aggNode.addValueNode("group", m_groupingParam, true); } // Add "totalobjects" if used. if (m_totalObjects >= 0) { resultsNode.addValueNode("totalobjects", Long.toString(m_totalObjects)); } // Add global or summary value if present. if (m_globalValue != null) { if (m_groupSetList == null) { resultsNode.addChildNode(UNode.createValueNode("value", m_globalValue)); } else { resultsNode.addChildNode(UNode.createValueNode("summary", m_globalValue)); } } // If needed, the "groupsets" node becomes the new parent. UNode parentNode = resultsNode; boolean bGroupSetsNode = false; if (m_groupSetList != null && m_groupSetList.size() > 1) { bGroupSetsNode = true; UNode groupSetsNode = parentNode.addArrayNode("groupsets"); parentNode = groupSetsNode; } // Add groupsets, if any, to the parent node. if (m_groupSetList != null) { for (AggGroupSet groupSet : m_groupSetList) { groupSet.addDoc(parentNode, bGroupSetsNode); } } return resultsNode; }
[ "public", "UNode", "toDoc", "(", ")", "{", "// Root \"results\" node.\r", "UNode", "resultsNode", "=", "UNode", ".", "createMapNode", "(", "\"results\"", ")", ";", "// \"aggregate\" node.\r", "UNode", "aggNode", "=", "resultsNode", ".", "addMapNode", "(", "\"aggregate\"", ")", ";", "aggNode", ".", "addValueNode", "(", "\"metric\"", ",", "m_metricParam", ",", "true", ")", ";", "if", "(", "m_queryParam", "!=", "null", ")", "{", "aggNode", ".", "addValueNode", "(", "\"query\"", ",", "m_queryParam", ",", "true", ")", ";", "}", "if", "(", "m_groupingParam", "!=", "null", ")", "{", "aggNode", ".", "addValueNode", "(", "\"group\"", ",", "m_groupingParam", ",", "true", ")", ";", "}", "// Add \"totalobjects\" if used.\r", "if", "(", "m_totalObjects", ">=", "0", ")", "{", "resultsNode", ".", "addValueNode", "(", "\"totalobjects\"", ",", "Long", ".", "toString", "(", "m_totalObjects", ")", ")", ";", "}", "// Add global or summary value if present.\r", "if", "(", "m_globalValue", "!=", "null", ")", "{", "if", "(", "m_groupSetList", "==", "null", ")", "{", "resultsNode", ".", "addChildNode", "(", "UNode", ".", "createValueNode", "(", "\"value\"", ",", "m_globalValue", ")", ")", ";", "}", "else", "{", "resultsNode", ".", "addChildNode", "(", "UNode", ".", "createValueNode", "(", "\"summary\"", ",", "m_globalValue", ")", ")", ";", "}", "}", "// If needed, the \"groupsets\" node becomes the new parent. \r", "UNode", "parentNode", "=", "resultsNode", ";", "boolean", "bGroupSetsNode", "=", "false", ";", "if", "(", "m_groupSetList", "!=", "null", "&&", "m_groupSetList", ".", "size", "(", ")", ">", "1", ")", "{", "bGroupSetsNode", "=", "true", ";", "UNode", "groupSetsNode", "=", "parentNode", ".", "addArrayNode", "(", "\"groupsets\"", ")", ";", "parentNode", "=", "groupSetsNode", ";", "}", "// Add groupsets, if any, to the parent node.\r", "if", "(", "m_groupSetList", "!=", "null", ")", "{", "for", "(", "AggGroupSet", "groupSet", ":", "m_groupSetList", ")", "{", "groupSet", ".", "addDoc", "(", "parentNode", ",", "bGroupSetsNode", ")", ";", "}", "}", "return", "resultsNode", ";", "}" ]
Serialize this AggregateResult object into a UNode tree and return the root node. The root node is "results". @return Root node of a UNode tree representing this AggregateResult object.
[ "Serialize", "this", "AggregateResult", "object", "into", "a", "UNode", "tree", "and", "return", "the", "root", "node", ".", "The", "root", "node", "is", "results", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/AggregateResult.java#L714-L758
138,065
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/core/IDGenerator.java
IDGenerator.nextID
public static byte[] nextID() { byte[] ID = new byte[15]; synchronized (LOCK) { long timestamp = System.currentTimeMillis(); if (timestamp != LAST_TIMESTAMP) { LAST_TIMESTAMP = timestamp; LAST_SEQUENCE = 0; TIMESTAMP_BUFFER[0] = (byte)(timestamp >>> 48); TIMESTAMP_BUFFER[1] = (byte)(timestamp >>> 40); TIMESTAMP_BUFFER[2] = (byte)(timestamp >>> 32); TIMESTAMP_BUFFER[3] = (byte)(timestamp >>> 24); TIMESTAMP_BUFFER[4] = (byte)(timestamp >>> 16); TIMESTAMP_BUFFER[5] = (byte)(timestamp >>> 8); TIMESTAMP_BUFFER[6] = (byte)(timestamp >>> 0); } else if (++LAST_SEQUENCE == 0) { throw new RuntimeException("Same ID generated in a single milliscond!"); } ByteBuffer bb = ByteBuffer.wrap(ID); bb.put(TIMESTAMP_BUFFER); bb.put(MAC); bb.putShort(LAST_SEQUENCE); } return ID; }
java
public static byte[] nextID() { byte[] ID = new byte[15]; synchronized (LOCK) { long timestamp = System.currentTimeMillis(); if (timestamp != LAST_TIMESTAMP) { LAST_TIMESTAMP = timestamp; LAST_SEQUENCE = 0; TIMESTAMP_BUFFER[0] = (byte)(timestamp >>> 48); TIMESTAMP_BUFFER[1] = (byte)(timestamp >>> 40); TIMESTAMP_BUFFER[2] = (byte)(timestamp >>> 32); TIMESTAMP_BUFFER[3] = (byte)(timestamp >>> 24); TIMESTAMP_BUFFER[4] = (byte)(timestamp >>> 16); TIMESTAMP_BUFFER[5] = (byte)(timestamp >>> 8); TIMESTAMP_BUFFER[6] = (byte)(timestamp >>> 0); } else if (++LAST_SEQUENCE == 0) { throw new RuntimeException("Same ID generated in a single milliscond!"); } ByteBuffer bb = ByteBuffer.wrap(ID); bb.put(TIMESTAMP_BUFFER); bb.put(MAC); bb.putShort(LAST_SEQUENCE); } return ID; }
[ "public", "static", "byte", "[", "]", "nextID", "(", ")", "{", "byte", "[", "]", "ID", "=", "new", "byte", "[", "15", "]", ";", "synchronized", "(", "LOCK", ")", "{", "long", "timestamp", "=", "System", ".", "currentTimeMillis", "(", ")", ";", "if", "(", "timestamp", "!=", "LAST_TIMESTAMP", ")", "{", "LAST_TIMESTAMP", "=", "timestamp", ";", "LAST_SEQUENCE", "=", "0", ";", "TIMESTAMP_BUFFER", "[", "0", "]", "=", "(", "byte", ")", "(", "timestamp", ">>>", "48", ")", ";", "TIMESTAMP_BUFFER", "[", "1", "]", "=", "(", "byte", ")", "(", "timestamp", ">>>", "40", ")", ";", "TIMESTAMP_BUFFER", "[", "2", "]", "=", "(", "byte", ")", "(", "timestamp", ">>>", "32", ")", ";", "TIMESTAMP_BUFFER", "[", "3", "]", "=", "(", "byte", ")", "(", "timestamp", ">>>", "24", ")", ";", "TIMESTAMP_BUFFER", "[", "4", "]", "=", "(", "byte", ")", "(", "timestamp", ">>>", "16", ")", ";", "TIMESTAMP_BUFFER", "[", "5", "]", "=", "(", "byte", ")", "(", "timestamp", ">>>", "8", ")", ";", "TIMESTAMP_BUFFER", "[", "6", "]", "=", "(", "byte", ")", "(", "timestamp", ">>>", "0", ")", ";", "}", "else", "if", "(", "++", "LAST_SEQUENCE", "==", "0", ")", "{", "throw", "new", "RuntimeException", "(", "\"Same ID generated in a single milliscond!\"", ")", ";", "}", "ByteBuffer", "bb", "=", "ByteBuffer", ".", "wrap", "(", "ID", ")", ";", "bb", ".", "put", "(", "TIMESTAMP_BUFFER", ")", ";", "bb", ".", "put", "(", "MAC", ")", ";", "bb", ".", "putShort", "(", "LAST_SEQUENCE", ")", ";", "}", "return", "ID", ";", "}" ]
Return the next unique ID. See the class description for the format of an ID. @return The next unique ID as a byte[15]. A new byte[] is allocated with each call so the caller can modify it.
[ "Return", "the", "next", "unique", "ID", ".", "See", "the", "class", "description", "for", "the", "format", "of", "an", "ID", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/core/IDGenerator.java#L78-L101
138,066
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/core/IDGenerator.java
IDGenerator.chooseMACAddress
private static byte[] chooseMACAddress() { byte[] result = new byte[6]; boolean bFound = false; try { Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces(); while (!bFound && ifaces.hasMoreElements()) { // Look for a real NIC. NetworkInterface iface = ifaces.nextElement(); try { byte[] hwAddress = iface.getHardwareAddress(); if (hwAddress != null) { int copyBytes = Math.min(result.length, hwAddress.length); for (int index = 0; index < copyBytes; index++) { result[index] = hwAddress[index]; } bFound = true; } } catch (SocketException e) { // Try next NIC } } } catch (SocketException e) { // Possibly no NICs on this system? } if (!bFound) { (new Random()).nextBytes(result); } return result; }
java
private static byte[] chooseMACAddress() { byte[] result = new byte[6]; boolean bFound = false; try { Enumeration<NetworkInterface> ifaces = NetworkInterface.getNetworkInterfaces(); while (!bFound && ifaces.hasMoreElements()) { // Look for a real NIC. NetworkInterface iface = ifaces.nextElement(); try { byte[] hwAddress = iface.getHardwareAddress(); if (hwAddress != null) { int copyBytes = Math.min(result.length, hwAddress.length); for (int index = 0; index < copyBytes; index++) { result[index] = hwAddress[index]; } bFound = true; } } catch (SocketException e) { // Try next NIC } } } catch (SocketException e) { // Possibly no NICs on this system? } if (!bFound) { (new Random()).nextBytes(result); } return result; }
[ "private", "static", "byte", "[", "]", "chooseMACAddress", "(", ")", "{", "byte", "[", "]", "result", "=", "new", "byte", "[", "6", "]", ";", "boolean", "bFound", "=", "false", ";", "try", "{", "Enumeration", "<", "NetworkInterface", ">", "ifaces", "=", "NetworkInterface", ".", "getNetworkInterfaces", "(", ")", ";", "while", "(", "!", "bFound", "&&", "ifaces", ".", "hasMoreElements", "(", ")", ")", "{", "// Look for a real NIC.\r", "NetworkInterface", "iface", "=", "ifaces", ".", "nextElement", "(", ")", ";", "try", "{", "byte", "[", "]", "hwAddress", "=", "iface", ".", "getHardwareAddress", "(", ")", ";", "if", "(", "hwAddress", "!=", "null", ")", "{", "int", "copyBytes", "=", "Math", ".", "min", "(", "result", ".", "length", ",", "hwAddress", ".", "length", ")", ";", "for", "(", "int", "index", "=", "0", ";", "index", "<", "copyBytes", ";", "index", "++", ")", "{", "result", "[", "index", "]", "=", "hwAddress", "[", "index", "]", ";", "}", "bFound", "=", "true", ";", "}", "}", "catch", "(", "SocketException", "e", ")", "{", "// Try next NIC\r", "}", "}", "}", "catch", "(", "SocketException", "e", ")", "{", "// Possibly no NICs on this system?\r", "}", "if", "(", "!", "bFound", ")", "{", "(", "new", "Random", "(", ")", ")", ".", "nextBytes", "(", "result", ")", ";", "}", "return", "result", ";", "}" ]
Choose a MAC address from one of this machine's NICs or a random value.
[ "Choose", "a", "MAC", "address", "from", "one", "of", "this", "machine", "s", "NICs", "or", "a", "random", "value", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/core/IDGenerator.java#L104-L132
138,067
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/search/util/HeapList.java
HeapList.Add
public boolean Add(T value) { if (m_Count < m_Capacity) { m_Array[++m_Count] = value; UpHeap(); } else if (greaterThan(m_Array[1], value)) { m_Array[1] = value; DownHeap(); } else return false; return true; }
java
public boolean Add(T value) { if (m_Count < m_Capacity) { m_Array[++m_Count] = value; UpHeap(); } else if (greaterThan(m_Array[1], value)) { m_Array[1] = value; DownHeap(); } else return false; return true; }
[ "public", "boolean", "Add", "(", "T", "value", ")", "{", "if", "(", "m_Count", "<", "m_Capacity", ")", "{", "m_Array", "[", "++", "m_Count", "]", "=", "value", ";", "UpHeap", "(", ")", ";", "}", "else", "if", "(", "greaterThan", "(", "m_Array", "[", "1", "]", ",", "value", ")", ")", "{", "m_Array", "[", "1", "]", "=", "value", ";", "DownHeap", "(", ")", ";", "}", "else", "return", "false", ";", "return", "true", ";", "}" ]
returns true if the value has been added
[ "returns", "true", "if", "the", "value", "has", "been", "added" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/search/util/HeapList.java#L79-L90
138,068
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/olap/CheckDatabase.java
CheckDatabase.checkShard
public static void checkShard(Olap olap, ApplicationDefinition appDef, String shard) { VDirectory appDir = olap.getRoot(appDef); VDirectory shardDir = appDir.getDirectory(shard); checkShard(shardDir); }
java
public static void checkShard(Olap olap, ApplicationDefinition appDef, String shard) { VDirectory appDir = olap.getRoot(appDef); VDirectory shardDir = appDir.getDirectory(shard); checkShard(shardDir); }
[ "public", "static", "void", "checkShard", "(", "Olap", "olap", ",", "ApplicationDefinition", "appDef", ",", "String", "shard", ")", "{", "VDirectory", "appDir", "=", "olap", ".", "getRoot", "(", "appDef", ")", ";", "VDirectory", "shardDir", "=", "appDir", ".", "getDirectory", "(", "shard", ")", ";", "checkShard", "(", "shardDir", ")", ";", "}" ]
check that all segments in the shard are valid
[ "check", "that", "all", "segments", "in", "the", "shard", "are", "valid" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/olap/CheckDatabase.java#L43-L47
138,069
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/olap/CheckDatabase.java
CheckDatabase.deleteSegment
public static void deleteSegment(Olap olap, ApplicationDefinition appDef, String shard, String segment) { VDirectory appDir = olap.getRoot(appDef); VDirectory shardDir = appDir.getDirectory(shard); VDirectory segmentDir = shardDir.getDirectory(segment); segmentDir.delete(); }
java
public static void deleteSegment(Olap olap, ApplicationDefinition appDef, String shard, String segment) { VDirectory appDir = olap.getRoot(appDef); VDirectory shardDir = appDir.getDirectory(shard); VDirectory segmentDir = shardDir.getDirectory(segment); segmentDir.delete(); }
[ "public", "static", "void", "deleteSegment", "(", "Olap", "olap", ",", "ApplicationDefinition", "appDef", ",", "String", "shard", ",", "String", "segment", ")", "{", "VDirectory", "appDir", "=", "olap", ".", "getRoot", "(", "appDef", ")", ";", "VDirectory", "shardDir", "=", "appDir", ".", "getDirectory", "(", "shard", ")", ";", "VDirectory", "segmentDir", "=", "shardDir", ".", "getDirectory", "(", "segment", ")", ";", "segmentDir", ".", "delete", "(", ")", ";", "}" ]
delete a particular segment in the shard.
[ "delete", "a", "particular", "segment", "in", "the", "shard", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/olap/CheckDatabase.java#L52-L57
138,070
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/rest/RESTRegistry.java
RESTRegistry.getCommands
public Collection<String> getCommands() { List<String> commands = new ArrayList<String>(); for (String cmdOwner : m_cmdsByOwnerMap.keySet()) { SortedMap<String, RESTCommand> ownerCmdMap = m_cmdsByOwnerMap.get(cmdOwner); for (String name : ownerCmdMap.keySet()) { RESTCommand cmd = ownerCmdMap.get(name); commands.add(String.format("%s: %s = %s", cmdOwner, name, cmd.toString())); } } return commands; }
java
public Collection<String> getCommands() { List<String> commands = new ArrayList<String>(); for (String cmdOwner : m_cmdsByOwnerMap.keySet()) { SortedMap<String, RESTCommand> ownerCmdMap = m_cmdsByOwnerMap.get(cmdOwner); for (String name : ownerCmdMap.keySet()) { RESTCommand cmd = ownerCmdMap.get(name); commands.add(String.format("%s: %s = %s", cmdOwner, name, cmd.toString())); } } return commands; }
[ "public", "Collection", "<", "String", ">", "getCommands", "(", ")", "{", "List", "<", "String", ">", "commands", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "String", "cmdOwner", ":", "m_cmdsByOwnerMap", ".", "keySet", "(", ")", ")", "{", "SortedMap", "<", "String", ",", "RESTCommand", ">", "ownerCmdMap", "=", "m_cmdsByOwnerMap", ".", "get", "(", "cmdOwner", ")", ";", "for", "(", "String", "name", ":", "ownerCmdMap", ".", "keySet", "(", ")", ")", "{", "RESTCommand", "cmd", "=", "ownerCmdMap", ".", "get", "(", "name", ")", ";", "commands", ".", "add", "(", "String", ".", "format", "(", "\"%s: %s = %s\"", ",", "cmdOwner", ",", "name", ",", "cmd", ".", "toString", "(", ")", ")", ")", ";", "}", "}", "return", "commands", ";", "}" ]
Get all REST commands as a list of strings for debugging purposes. @return List of commands for debugging.
[ "Get", "all", "REST", "commands", "as", "a", "list", "of", "strings", "for", "debugging", "purposes", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/rest/RESTRegistry.java#L205-L215
138,071
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/rest/RESTRegistry.java
RESTRegistry.registerCommand
private void registerCommand(String cmdOwner, RegisteredCommand cmd) { // Add to owner map in RESTCatalog. Map<String, RESTCommand> nameMap = getCmdNameMap(cmdOwner); String cmdName = cmd.getName(); RESTCommand oldCmd = nameMap.put(cmdName, cmd); if (oldCmd != null) { throw new RuntimeException("Duplicate REST command with same owner/name: " + "owner=" + cmdOwner + ", name=" + cmdName + ", [1]=" + cmd + ", [2]=" + oldCmd); } // Add to local evaluation map. Map<HttpMethod, SortedSet<RegisteredCommand>> evalMap = getCmdEvalMap(cmdOwner); for (HttpMethod method : cmd.getMethods()) { SortedSet<RegisteredCommand> methodSet = evalMap.get(method); if (methodSet == null) { methodSet = new TreeSet<>(); evalMap.put(method, methodSet); } if (!methodSet.add(cmd)) { throw new RuntimeException("Duplicate REST command: owner=" + cmdOwner + ", name=" + cmdName + ", commmand=" + cmd); } } }
java
private void registerCommand(String cmdOwner, RegisteredCommand cmd) { // Add to owner map in RESTCatalog. Map<String, RESTCommand> nameMap = getCmdNameMap(cmdOwner); String cmdName = cmd.getName(); RESTCommand oldCmd = nameMap.put(cmdName, cmd); if (oldCmd != null) { throw new RuntimeException("Duplicate REST command with same owner/name: " + "owner=" + cmdOwner + ", name=" + cmdName + ", [1]=" + cmd + ", [2]=" + oldCmd); } // Add to local evaluation map. Map<HttpMethod, SortedSet<RegisteredCommand>> evalMap = getCmdEvalMap(cmdOwner); for (HttpMethod method : cmd.getMethods()) { SortedSet<RegisteredCommand> methodSet = evalMap.get(method); if (methodSet == null) { methodSet = new TreeSet<>(); evalMap.put(method, methodSet); } if (!methodSet.add(cmd)) { throw new RuntimeException("Duplicate REST command: owner=" + cmdOwner + ", name=" + cmdName + ", commmand=" + cmd); } } }
[ "private", "void", "registerCommand", "(", "String", "cmdOwner", ",", "RegisteredCommand", "cmd", ")", "{", "// Add to owner map in RESTCatalog.\r", "Map", "<", "String", ",", "RESTCommand", ">", "nameMap", "=", "getCmdNameMap", "(", "cmdOwner", ")", ";", "String", "cmdName", "=", "cmd", ".", "getName", "(", ")", ";", "RESTCommand", "oldCmd", "=", "nameMap", ".", "put", "(", "cmdName", ",", "cmd", ")", ";", "if", "(", "oldCmd", "!=", "null", ")", "{", "throw", "new", "RuntimeException", "(", "\"Duplicate REST command with same owner/name: \"", "+", "\"owner=\"", "+", "cmdOwner", "+", "\", name=\"", "+", "cmdName", "+", "\", [1]=\"", "+", "cmd", "+", "\", [2]=\"", "+", "oldCmd", ")", ";", "}", "// Add to local evaluation map.\r", "Map", "<", "HttpMethod", ",", "SortedSet", "<", "RegisteredCommand", ">", ">", "evalMap", "=", "getCmdEvalMap", "(", "cmdOwner", ")", ";", "for", "(", "HttpMethod", "method", ":", "cmd", ".", "getMethods", "(", ")", ")", "{", "SortedSet", "<", "RegisteredCommand", ">", "methodSet", "=", "evalMap", ".", "get", "(", "method", ")", ";", "if", "(", "methodSet", "==", "null", ")", "{", "methodSet", "=", "new", "TreeSet", "<>", "(", ")", ";", "evalMap", ".", "put", "(", "method", ",", "methodSet", ")", ";", "}", "if", "(", "!", "methodSet", ".", "add", "(", "cmd", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"Duplicate REST command: owner=\"", "+", "cmdOwner", "+", "\", name=\"", "+", "cmdName", "+", "\", commmand=\"", "+", "cmd", ")", ";", "}", "}", "}" ]
Register the given command and throw if is a duplicate name or command.
[ "Register", "the", "given", "command", "and", "throw", "if", "is", "a", "duplicate", "name", "or", "command", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/rest/RESTRegistry.java#L220-L245
138,072
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/rest/RESTRegistry.java
RESTRegistry.getCmdNameMap
private Map<String, RESTCommand> getCmdNameMap(String cmdOwner) { SortedMap<String, RESTCommand> cmdNameMap = m_cmdsByOwnerMap.get(cmdOwner); if (cmdNameMap == null) { cmdNameMap = new TreeMap<>(); m_cmdsByOwnerMap.put(cmdOwner, cmdNameMap); } return cmdNameMap; }
java
private Map<String, RESTCommand> getCmdNameMap(String cmdOwner) { SortedMap<String, RESTCommand> cmdNameMap = m_cmdsByOwnerMap.get(cmdOwner); if (cmdNameMap == null) { cmdNameMap = new TreeMap<>(); m_cmdsByOwnerMap.put(cmdOwner, cmdNameMap); } return cmdNameMap; }
[ "private", "Map", "<", "String", ",", "RESTCommand", ">", "getCmdNameMap", "(", "String", "cmdOwner", ")", "{", "SortedMap", "<", "String", ",", "RESTCommand", ">", "cmdNameMap", "=", "m_cmdsByOwnerMap", ".", "get", "(", "cmdOwner", ")", ";", "if", "(", "cmdNameMap", "==", "null", ")", "{", "cmdNameMap", "=", "new", "TreeMap", "<>", "(", ")", ";", "m_cmdsByOwnerMap", ".", "put", "(", "cmdOwner", ",", "cmdNameMap", ")", ";", "}", "return", "cmdNameMap", ";", "}" ]
Get the method -> command map for the given owner.
[ "Get", "the", "method", "-", ">", "command", "map", "for", "the", "given", "owner", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/rest/RESTRegistry.java#L248-L255
138,073
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/rest/RESTRegistry.java
RESTRegistry.getCmdEvalMap
private Map<HttpMethod, SortedSet<RegisteredCommand>> getCmdEvalMap(String cmdOwner) { Map<HttpMethod, SortedSet<RegisteredCommand>> evalMap = m_cmdEvalMap.get(cmdOwner); if (evalMap == null) { evalMap = new HashMap<>(); m_cmdEvalMap.put(cmdOwner, evalMap); } return evalMap; }
java
private Map<HttpMethod, SortedSet<RegisteredCommand>> getCmdEvalMap(String cmdOwner) { Map<HttpMethod, SortedSet<RegisteredCommand>> evalMap = m_cmdEvalMap.get(cmdOwner); if (evalMap == null) { evalMap = new HashMap<>(); m_cmdEvalMap.put(cmdOwner, evalMap); } return evalMap; }
[ "private", "Map", "<", "HttpMethod", ",", "SortedSet", "<", "RegisteredCommand", ">", ">", "getCmdEvalMap", "(", "String", "cmdOwner", ")", "{", "Map", "<", "HttpMethod", ",", "SortedSet", "<", "RegisteredCommand", ">", ">", "evalMap", "=", "m_cmdEvalMap", ".", "get", "(", "cmdOwner", ")", ";", "if", "(", "evalMap", "==", "null", ")", "{", "evalMap", "=", "new", "HashMap", "<>", "(", ")", ";", "m_cmdEvalMap", ".", "put", "(", "cmdOwner", ",", "evalMap", ")", ";", "}", "return", "evalMap", ";", "}" ]
Get the method -> sorted command map for the given owner.
[ "Get", "the", "method", "-", ">", "sorted", "command", "map", "for", "the", "given", "owner", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/rest/RESTRegistry.java#L258-L265
138,074
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/rest/RESTRegistry.java
RESTRegistry.searchCommands
private RegisteredCommand searchCommands(String cmdOwner, HttpMethod method, String uri, String query, Map<String, String> variableMap) { Map<HttpMethod, SortedSet<RegisteredCommand>> evalMap = getCmdEvalMap(cmdOwner); if (evalMap == null) { return null; } // Find the sorted command set for the given HTTP method. SortedSet<RegisteredCommand> cmdSet = evalMap.get(method); if (cmdSet == null) { return null; } // Split uri into a list of non-empty nodes. List<String> pathNodeList = new ArrayList<>(); String[] pathNodes = uri.split("/"); for (String pathNode : pathNodes) { if (pathNode.length() > 0) { pathNodeList.add(pathNode); } } // Attempt to match commands in this set in order. for (RegisteredCommand cmd : cmdSet) { if (cmd.matches(pathNodeList, query, variableMap)) { return cmd; } } return null; }
java
private RegisteredCommand searchCommands(String cmdOwner, HttpMethod method, String uri, String query, Map<String, String> variableMap) { Map<HttpMethod, SortedSet<RegisteredCommand>> evalMap = getCmdEvalMap(cmdOwner); if (evalMap == null) { return null; } // Find the sorted command set for the given HTTP method. SortedSet<RegisteredCommand> cmdSet = evalMap.get(method); if (cmdSet == null) { return null; } // Split uri into a list of non-empty nodes. List<String> pathNodeList = new ArrayList<>(); String[] pathNodes = uri.split("/"); for (String pathNode : pathNodes) { if (pathNode.length() > 0) { pathNodeList.add(pathNode); } } // Attempt to match commands in this set in order. for (RegisteredCommand cmd : cmdSet) { if (cmd.matches(pathNodeList, query, variableMap)) { return cmd; } } return null; }
[ "private", "RegisteredCommand", "searchCommands", "(", "String", "cmdOwner", ",", "HttpMethod", "method", ",", "String", "uri", ",", "String", "query", ",", "Map", "<", "String", ",", "String", ">", "variableMap", ")", "{", "Map", "<", "HttpMethod", ",", "SortedSet", "<", "RegisteredCommand", ">", ">", "evalMap", "=", "getCmdEvalMap", "(", "cmdOwner", ")", ";", "if", "(", "evalMap", "==", "null", ")", "{", "return", "null", ";", "}", "// Find the sorted command set for the given HTTP method.\r", "SortedSet", "<", "RegisteredCommand", ">", "cmdSet", "=", "evalMap", ".", "get", "(", "method", ")", ";", "if", "(", "cmdSet", "==", "null", ")", "{", "return", "null", ";", "}", "// Split uri into a list of non-empty nodes.\r", "List", "<", "String", ">", "pathNodeList", "=", "new", "ArrayList", "<>", "(", ")", ";", "String", "[", "]", "pathNodes", "=", "uri", ".", "split", "(", "\"/\"", ")", ";", "for", "(", "String", "pathNode", ":", "pathNodes", ")", "{", "if", "(", "pathNode", ".", "length", "(", ")", ">", "0", ")", "{", "pathNodeList", ".", "add", "(", "pathNode", ")", ";", "}", "}", "// Attempt to match commands in this set in order.\r", "for", "(", "RegisteredCommand", "cmd", ":", "cmdSet", ")", "{", "if", "(", "cmd", ".", "matches", "(", "pathNodeList", ",", "query", ",", "variableMap", ")", ")", "{", "return", "cmd", ";", "}", "}", "return", "null", ";", "}" ]
Search the given command owner for a matching command.
[ "Search", "the", "given", "command", "owner", "for", "a", "matching", "command", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/rest/RESTRegistry.java#L268-L297
138,075
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/client/Client.java
Client.deleteApplication
public boolean deleteApplication(String appName, String key) { Utils.require(!m_restClient.isClosed(), "Client has been closed"); Utils.require(appName != null && appName.length() > 0, "appName"); try { // Send a DELETE request to "/_applications/{application}/{key}". StringBuilder uri = new StringBuilder(Utils.isEmpty(m_apiPrefix) ? "" : "/" + m_apiPrefix); uri.append("/_applications/"); uri.append(Utils.urlEncode(appName)); if (!Utils.isEmpty(key)) { uri.append("/"); uri.append(Utils.urlEncode(key)); } RESTResponse response = m_restClient.sendRequest(HttpMethod.DELETE, uri.toString()); m_logger.debug("deleteApplication() response: {}", response.toString()); if (response.getCode() != HttpCode.NOT_FOUND) { // Notfound is acceptable throwIfErrorResponse(response); } return true; } catch (Exception e) { throw new RuntimeException(e); } }
java
public boolean deleteApplication(String appName, String key) { Utils.require(!m_restClient.isClosed(), "Client has been closed"); Utils.require(appName != null && appName.length() > 0, "appName"); try { // Send a DELETE request to "/_applications/{application}/{key}". StringBuilder uri = new StringBuilder(Utils.isEmpty(m_apiPrefix) ? "" : "/" + m_apiPrefix); uri.append("/_applications/"); uri.append(Utils.urlEncode(appName)); if (!Utils.isEmpty(key)) { uri.append("/"); uri.append(Utils.urlEncode(key)); } RESTResponse response = m_restClient.sendRequest(HttpMethod.DELETE, uri.toString()); m_logger.debug("deleteApplication() response: {}", response.toString()); if (response.getCode() != HttpCode.NOT_FOUND) { // Notfound is acceptable throwIfErrorResponse(response); } return true; } catch (Exception e) { throw new RuntimeException(e); } }
[ "public", "boolean", "deleteApplication", "(", "String", "appName", ",", "String", "key", ")", "{", "Utils", ".", "require", "(", "!", "m_restClient", ".", "isClosed", "(", ")", ",", "\"Client has been closed\"", ")", ";", "Utils", ".", "require", "(", "appName", "!=", "null", "&&", "appName", ".", "length", "(", ")", ">", "0", ",", "\"appName\"", ")", ";", "try", "{", "// Send a DELETE request to \"/_applications/{application}/{key}\".\r", "StringBuilder", "uri", "=", "new", "StringBuilder", "(", "Utils", ".", "isEmpty", "(", "m_apiPrefix", ")", "?", "\"\"", ":", "\"/\"", "+", "m_apiPrefix", ")", ";", "uri", ".", "append", "(", "\"/_applications/\"", ")", ";", "uri", ".", "append", "(", "Utils", ".", "urlEncode", "(", "appName", ")", ")", ";", "if", "(", "!", "Utils", ".", "isEmpty", "(", "key", ")", ")", "{", "uri", ".", "append", "(", "\"/\"", ")", ";", "uri", ".", "append", "(", "Utils", ".", "urlEncode", "(", "key", ")", ")", ";", "}", "RESTResponse", "response", "=", "m_restClient", ".", "sendRequest", "(", "HttpMethod", ".", "DELETE", ",", "uri", ".", "toString", "(", ")", ")", ";", "m_logger", ".", "debug", "(", "\"deleteApplication() response: {}\"", ",", "response", ".", "toString", "(", ")", ")", ";", "if", "(", "response", ".", "getCode", "(", ")", "!=", "HttpCode", ".", "NOT_FOUND", ")", "{", "// Notfound is acceptable\r", "throwIfErrorResponse", "(", "response", ")", ";", "}", "return", "true", ";", "}", "catch", "(", "Exception", "e", ")", "{", "throw", "new", "RuntimeException", "(", "e", ")", ";", "}", "}" ]
Delete an existing application from the current Doradus tenant, including all of its tables and data. Because updates are idempotent, deleting an already-deleted application is acceptable. Hence, if no error is thrown, the result is always true. An exception is thrown if an error occurs. @param appName Name of existing application to delete. @param key Key of application to delete. Can be null if the application has no key. @return True if the application was deleted or already deleted.
[ "Delete", "an", "existing", "application", "from", "the", "current", "Doradus", "tenant", "including", "all", "of", "its", "tables", "and", "data", ".", "Because", "updates", "are", "idempotent", "deleting", "an", "already", "-", "deleted", "application", "is", "acceptable", ".", "Hence", "if", "no", "error", "is", "thrown", "the", "result", "is", "always", "true", ".", "An", "exception", "is", "thrown", "if", "an", "error", "occurs", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/Client.java#L403-L426
138,076
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/client/Client.java
Client.openApplication
private static ApplicationSession openApplication(ApplicationDefinition appDef, RESTClient restClient) { String storageService = appDef.getStorageService(); if (storageService == null || storageService.length() <= "Service".length() || !storageService.endsWith("Service")) { throw new RuntimeException("Unknown storage-service for application '" + appDef.getAppName() + "': " + storageService); } // Using the application's StorageService, attempt to create an instance of the // ApplicationSession subclass XxxSession where Xxx is the storage prefix. try { String prefix = storageService.substring(0, storageService.length() - "Service".length()); String className = Client.class.getPackage().getName() + "." + prefix + "Session"; @SuppressWarnings("unchecked") Class<ApplicationSession> appClass = (Class<ApplicationSession>) Class.forName(className); Constructor<ApplicationSession> constructor = appClass.getConstructor(ApplicationDefinition.class, RESTClient.class); ApplicationSession appSession = constructor.newInstance(appDef, restClient); return appSession; } catch (Exception e) { restClient.close(); throw new RuntimeException("Unable to load session class", e); } }
java
private static ApplicationSession openApplication(ApplicationDefinition appDef, RESTClient restClient) { String storageService = appDef.getStorageService(); if (storageService == null || storageService.length() <= "Service".length() || !storageService.endsWith("Service")) { throw new RuntimeException("Unknown storage-service for application '" + appDef.getAppName() + "': " + storageService); } // Using the application's StorageService, attempt to create an instance of the // ApplicationSession subclass XxxSession where Xxx is the storage prefix. try { String prefix = storageService.substring(0, storageService.length() - "Service".length()); String className = Client.class.getPackage().getName() + "." + prefix + "Session"; @SuppressWarnings("unchecked") Class<ApplicationSession> appClass = (Class<ApplicationSession>) Class.forName(className); Constructor<ApplicationSession> constructor = appClass.getConstructor(ApplicationDefinition.class, RESTClient.class); ApplicationSession appSession = constructor.newInstance(appDef, restClient); return appSession; } catch (Exception e) { restClient.close(); throw new RuntimeException("Unable to load session class", e); } }
[ "private", "static", "ApplicationSession", "openApplication", "(", "ApplicationDefinition", "appDef", ",", "RESTClient", "restClient", ")", "{", "String", "storageService", "=", "appDef", ".", "getStorageService", "(", ")", ";", "if", "(", "storageService", "==", "null", "||", "storageService", ".", "length", "(", ")", "<=", "\"Service\"", ".", "length", "(", ")", "||", "!", "storageService", ".", "endsWith", "(", "\"Service\"", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"Unknown storage-service for application '\"", "+", "appDef", ".", "getAppName", "(", ")", "+", "\"': \"", "+", "storageService", ")", ";", "}", "// Using the application's StorageService, attempt to create an instance of the\r", "// ApplicationSession subclass XxxSession where Xxx is the storage prefix.\r", "try", "{", "String", "prefix", "=", "storageService", ".", "substring", "(", "0", ",", "storageService", ".", "length", "(", ")", "-", "\"Service\"", ".", "length", "(", ")", ")", ";", "String", "className", "=", "Client", ".", "class", ".", "getPackage", "(", ")", ".", "getName", "(", ")", "+", "\".\"", "+", "prefix", "+", "\"Session\"", ";", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Class", "<", "ApplicationSession", ">", "appClass", "=", "(", "Class", "<", "ApplicationSession", ">", ")", "Class", ".", "forName", "(", "className", ")", ";", "Constructor", "<", "ApplicationSession", ">", "constructor", "=", "appClass", ".", "getConstructor", "(", "ApplicationDefinition", ".", "class", ",", "RESTClient", ".", "class", ")", ";", "ApplicationSession", "appSession", "=", "constructor", ".", "newInstance", "(", "appDef", ",", "restClient", ")", ";", "return", "appSession", ";", "}", "catch", "(", "Exception", "e", ")", "{", "restClient", ".", "close", "(", ")", ";", "throw", "new", "RuntimeException", "(", "\"Unable to load session class\"", ",", "e", ")", ";", "}", "}" ]
the given restClient. If the open fails, the restClient is closed.
[ "the", "given", "restClient", ".", "If", "the", "open", "fails", "the", "restClient", "is", "closed", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/Client.java#L432-L454
138,077
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/management/MBeanProxyFactory.java
MBeanProxyFactory.createServerMonitorProxy
public ServerMonitorMXBean createServerMonitorProxy() throws IOException { String beanName = ServerMonitorMXBean.JMX_DOMAIN_NAME + ":type=" + ServerMonitorMXBean.JMX_TYPE_NAME; return createMXBeanProxy(beanName, ServerMonitorMXBean.class); }
java
public ServerMonitorMXBean createServerMonitorProxy() throws IOException { String beanName = ServerMonitorMXBean.JMX_DOMAIN_NAME + ":type=" + ServerMonitorMXBean.JMX_TYPE_NAME; return createMXBeanProxy(beanName, ServerMonitorMXBean.class); }
[ "public", "ServerMonitorMXBean", "createServerMonitorProxy", "(", ")", "throws", "IOException", "{", "String", "beanName", "=", "ServerMonitorMXBean", ".", "JMX_DOMAIN_NAME", "+", "\":type=\"", "+", "ServerMonitorMXBean", ".", "JMX_TYPE_NAME", ";", "return", "createMXBeanProxy", "(", "beanName", ",", "ServerMonitorMXBean", ".", "class", ")", ";", "}" ]
Makes the proxy for ServerMonitorMXBean. @return A ServerMonitorMXBean proxy object. @throws IOException
[ "Makes", "the", "proxy", "for", "ServerMonitorMXBean", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/management/MBeanProxyFactory.java#L79-L82
138,078
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/management/MBeanProxyFactory.java
MBeanProxyFactory.createStorageManagerProxy
public StorageManagerMXBean createStorageManagerProxy() throws IOException { String beanName = StorageManagerMXBean.JMX_DOMAIN_NAME + ":type=" + StorageManagerMXBean.JMX_TYPE_NAME; return createMXBeanProxy(beanName, StorageManagerMXBean.class); }
java
public StorageManagerMXBean createStorageManagerProxy() throws IOException { String beanName = StorageManagerMXBean.JMX_DOMAIN_NAME + ":type=" + StorageManagerMXBean.JMX_TYPE_NAME; return createMXBeanProxy(beanName, StorageManagerMXBean.class); }
[ "public", "StorageManagerMXBean", "createStorageManagerProxy", "(", ")", "throws", "IOException", "{", "String", "beanName", "=", "StorageManagerMXBean", ".", "JMX_DOMAIN_NAME", "+", "\":type=\"", "+", "StorageManagerMXBean", ".", "JMX_TYPE_NAME", ";", "return", "createMXBeanProxy", "(", "beanName", ",", "StorageManagerMXBean", ".", "class", ")", ";", "}" ]
Makes the proxy for StorageManagerMXBean. @return A StorageManagerMXBean object. @throws IOException
[ "Makes", "the", "proxy", "for", "StorageManagerMXBean", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/management/MBeanProxyFactory.java#L89-L92
138,079
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/mbeans/StorageManager.java
StorageManager.getOperationMode
@Override public String getOperationMode() { String mode = getNode().getOperationMode(); if(mode != null && NORMAL.equals(mode.toUpperCase())) { mode = NORMAL; } return mode; }
java
@Override public String getOperationMode() { String mode = getNode().getOperationMode(); if(mode != null && NORMAL.equals(mode.toUpperCase())) { mode = NORMAL; } return mode; }
[ "@", "Override", "public", "String", "getOperationMode", "(", ")", "{", "String", "mode", "=", "getNode", "(", ")", ".", "getOperationMode", "(", ")", ";", "if", "(", "mode", "!=", "null", "&&", "NORMAL", ".", "equals", "(", "mode", ".", "toUpperCase", "(", ")", ")", ")", "{", "mode", "=", "NORMAL", ";", "}", "return", "mode", ";", "}" ]
The operation mode of the Cassandra node. @return one of: NORMAL, CLIENT, JOINING, LEAVING, DECOMMISSIONED, MOVING, DRAINING, or DRAINED.
[ "The", "operation", "mode", "of", "the", "Cassandra", "node", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/mbeans/StorageManager.java#L90-L97
138,080
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/search/aggregate/Aggregate.java
Aggregate.collectGroupValues
private void collectGroupValues(Entity obj, PathEntry entry, GroupSetEntry groupSetEntry, Set<String>[] groupKeys) { if(entry.query != null) { timers.start("Where", entry.queryText); boolean result = entry.checkCondition(obj); timers.stop("Where", entry.queryText, result ? 1 : 0); if (!result) return; } for(PathEntry field : entry.leafBranches) { String fieldName = field.name; int groupIndex = field.groupIndex; if(fieldName == PathEntry.ANY) { groupSetEntry.m_groupPaths[groupIndex].addValueKeys(groupKeys[groupIndex], obj.id().toString()); } else { String value = obj.get(fieldName); if(value == null || value.indexOf(CommonDefs.MV_SCALAR_SEP_CHAR) == -1) { groupSetEntry.m_groupPaths[groupIndex].addValueKeys(groupKeys[groupIndex], value); } else { String[] values = value.split(CommonDefs.MV_SCALAR_SEP_CHAR); for(String collectionValue : values) { groupSetEntry.m_groupPaths[groupIndex].addValueKeys(groupKeys[groupIndex], collectionValue); } } } } for(PathEntry child : entry.linkBranches) { boolean hasLinkedEntities = false; if(child.nestedLinks == null || child.nestedLinks.size() == 0) { for(Entity linkedObj : obj.getLinkedEntities(child.name, child.fieldNames)) { hasLinkedEntities = true; collectGroupValues(linkedObj, child, groupSetEntry, groupKeys); } } else { for(LinkInfo linkInfo : child.nestedLinks) { for(Entity linkedObj : obj.getLinkedEntities(linkInfo.name, child.fieldNames)) { hasLinkedEntities = true; collectGroupValues(linkedObj, child, groupSetEntry, groupKeys); } } } if(!hasLinkedEntities && !child.hasUnderlyingQuery()) nullifyGroupKeys(child, groupSetEntry, groupKeys); } }
java
private void collectGroupValues(Entity obj, PathEntry entry, GroupSetEntry groupSetEntry, Set<String>[] groupKeys) { if(entry.query != null) { timers.start("Where", entry.queryText); boolean result = entry.checkCondition(obj); timers.stop("Where", entry.queryText, result ? 1 : 0); if (!result) return; } for(PathEntry field : entry.leafBranches) { String fieldName = field.name; int groupIndex = field.groupIndex; if(fieldName == PathEntry.ANY) { groupSetEntry.m_groupPaths[groupIndex].addValueKeys(groupKeys[groupIndex], obj.id().toString()); } else { String value = obj.get(fieldName); if(value == null || value.indexOf(CommonDefs.MV_SCALAR_SEP_CHAR) == -1) { groupSetEntry.m_groupPaths[groupIndex].addValueKeys(groupKeys[groupIndex], value); } else { String[] values = value.split(CommonDefs.MV_SCALAR_SEP_CHAR); for(String collectionValue : values) { groupSetEntry.m_groupPaths[groupIndex].addValueKeys(groupKeys[groupIndex], collectionValue); } } } } for(PathEntry child : entry.linkBranches) { boolean hasLinkedEntities = false; if(child.nestedLinks == null || child.nestedLinks.size() == 0) { for(Entity linkedObj : obj.getLinkedEntities(child.name, child.fieldNames)) { hasLinkedEntities = true; collectGroupValues(linkedObj, child, groupSetEntry, groupKeys); } } else { for(LinkInfo linkInfo : child.nestedLinks) { for(Entity linkedObj : obj.getLinkedEntities(linkInfo.name, child.fieldNames)) { hasLinkedEntities = true; collectGroupValues(linkedObj, child, groupSetEntry, groupKeys); } } } if(!hasLinkedEntities && !child.hasUnderlyingQuery()) nullifyGroupKeys(child, groupSetEntry, groupKeys); } }
[ "private", "void", "collectGroupValues", "(", "Entity", "obj", ",", "PathEntry", "entry", ",", "GroupSetEntry", "groupSetEntry", ",", "Set", "<", "String", ">", "[", "]", "groupKeys", ")", "{", "if", "(", "entry", ".", "query", "!=", "null", ")", "{", "timers", ".", "start", "(", "\"Where\"", ",", "entry", ".", "queryText", ")", ";", "boolean", "result", "=", "entry", ".", "checkCondition", "(", "obj", ")", ";", "timers", ".", "stop", "(", "\"Where\"", ",", "entry", ".", "queryText", ",", "result", "?", "1", ":", "0", ")", ";", "if", "(", "!", "result", ")", "return", ";", "}", "for", "(", "PathEntry", "field", ":", "entry", ".", "leafBranches", ")", "{", "String", "fieldName", "=", "field", ".", "name", ";", "int", "groupIndex", "=", "field", ".", "groupIndex", ";", "if", "(", "fieldName", "==", "PathEntry", ".", "ANY", ")", "{", "groupSetEntry", ".", "m_groupPaths", "[", "groupIndex", "]", ".", "addValueKeys", "(", "groupKeys", "[", "groupIndex", "]", ",", "obj", ".", "id", "(", ")", ".", "toString", "(", ")", ")", ";", "}", "else", "{", "String", "value", "=", "obj", ".", "get", "(", "fieldName", ")", ";", "if", "(", "value", "==", "null", "||", "value", ".", "indexOf", "(", "CommonDefs", ".", "MV_SCALAR_SEP_CHAR", ")", "==", "-", "1", ")", "{", "groupSetEntry", ".", "m_groupPaths", "[", "groupIndex", "]", ".", "addValueKeys", "(", "groupKeys", "[", "groupIndex", "]", ",", "value", ")", ";", "}", "else", "{", "String", "[", "]", "values", "=", "value", ".", "split", "(", "CommonDefs", ".", "MV_SCALAR_SEP_CHAR", ")", ";", "for", "(", "String", "collectionValue", ":", "values", ")", "{", "groupSetEntry", ".", "m_groupPaths", "[", "groupIndex", "]", ".", "addValueKeys", "(", "groupKeys", "[", "groupIndex", "]", ",", "collectionValue", ")", ";", "}", "}", "}", "}", "for", "(", "PathEntry", "child", ":", "entry", ".", "linkBranches", ")", "{", "boolean", "hasLinkedEntities", "=", "false", ";", "if", "(", "child", ".", "nestedLinks", "==", "null", "||", "child", ".", "nestedLinks", ".", "size", "(", ")", "==", "0", ")", "{", "for", "(", "Entity", "linkedObj", ":", "obj", ".", "getLinkedEntities", "(", "child", ".", "name", ",", "child", ".", "fieldNames", ")", ")", "{", "hasLinkedEntities", "=", "true", ";", "collectGroupValues", "(", "linkedObj", ",", "child", ",", "groupSetEntry", ",", "groupKeys", ")", ";", "}", "}", "else", "{", "for", "(", "LinkInfo", "linkInfo", ":", "child", ".", "nestedLinks", ")", "{", "for", "(", "Entity", "linkedObj", ":", "obj", ".", "getLinkedEntities", "(", "linkInfo", ".", "name", ",", "child", ".", "fieldNames", ")", ")", "{", "hasLinkedEntities", "=", "true", ";", "collectGroupValues", "(", "linkedObj", ",", "child", ",", "groupSetEntry", ",", "groupKeys", ")", ";", "}", "}", "}", "if", "(", "!", "hasLinkedEntities", "&&", "!", "child", ".", "hasUnderlyingQuery", "(", ")", ")", "nullifyGroupKeys", "(", "child", ",", "groupSetEntry", ",", "groupKeys", ")", ";", "}", "}" ]
Collect all values from all object found in the path subtree
[ "Collect", "all", "values", "from", "all", "object", "found", "in", "the", "path", "subtree" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/search/aggregate/Aggregate.java#L333-L379
138,081
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/search/aggregate/Aggregate.java
Aggregate.updateMetric
private void updateMetric(String value, GroupSetEntry groupSetEntry, Set<String>[] groupKeys){ updateMetric(value, groupSetEntry.m_totalGroup, groupKeys, 0); if (groupSetEntry.m_isComposite){ updateMetric(value, groupSetEntry.m_compositeGroup, groupKeys, groupKeys.length - 1); } }
java
private void updateMetric(String value, GroupSetEntry groupSetEntry, Set<String>[] groupKeys){ updateMetric(value, groupSetEntry.m_totalGroup, groupKeys, 0); if (groupSetEntry.m_isComposite){ updateMetric(value, groupSetEntry.m_compositeGroup, groupKeys, groupKeys.length - 1); } }
[ "private", "void", "updateMetric", "(", "String", "value", ",", "GroupSetEntry", "groupSetEntry", ",", "Set", "<", "String", ">", "[", "]", "groupKeys", ")", "{", "updateMetric", "(", "value", ",", "groupSetEntry", ".", "m_totalGroup", ",", "groupKeys", ",", "0", ")", ";", "if", "(", "groupSetEntry", ".", "m_isComposite", ")", "{", "updateMetric", "(", "value", ",", "groupSetEntry", ".", "m_compositeGroup", ",", "groupKeys", ",", "groupKeys", ".", "length", "-", "1", ")", ";", "}", "}" ]
add value to the aggregation groups
[ "add", "value", "to", "the", "aggregation", "groups" ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/search/aggregate/Aggregate.java#L393-L398
138,082
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/search/aggregate/Aggregate.java
Aggregate.updateMetric
private synchronized void updateMetric(String value, Group group, Set<String>[] groupKeys, int index){ group.update(value); if (index < groupKeys.length){ for (String key : groupKeys[index]){ Group subgroup = group.subgroup(key); updateMetric(value, subgroup, groupKeys, index + 1); } } }
java
private synchronized void updateMetric(String value, Group group, Set<String>[] groupKeys, int index){ group.update(value); if (index < groupKeys.length){ for (String key : groupKeys[index]){ Group subgroup = group.subgroup(key); updateMetric(value, subgroup, groupKeys, index + 1); } } }
[ "private", "synchronized", "void", "updateMetric", "(", "String", "value", ",", "Group", "group", ",", "Set", "<", "String", ">", "[", "]", "groupKeys", ",", "int", "index", ")", "{", "group", ".", "update", "(", "value", ")", ";", "if", "(", "index", "<", "groupKeys", ".", "length", ")", "{", "for", "(", "String", "key", ":", "groupKeys", "[", "index", "]", ")", "{", "Group", "subgroup", "=", "group", ".", "subgroup", "(", "key", ")", ";", "updateMetric", "(", "value", ",", "subgroup", ",", "groupKeys", ",", "index", "+", "1", ")", ";", "}", "}", "}" ]
add value to the aggregation group and all subgroups in accordance with the groupKeys paths.
[ "add", "value", "to", "the", "aggregation", "group", "and", "all", "subgroups", "in", "accordance", "with", "the", "groupKeys", "paths", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/search/aggregate/Aggregate.java#L401-L409
138,083
QSFT/Doradus
doradus-common/src/main/java/com/dell/doradus/common/RetentionAge.java
RetentionAge.getExpiredDate
public GregorianCalendar getExpiredDate(GregorianCalendar relativeDate) { // Get today's date and adjust by the specified age. GregorianCalendar expiredDate = (GregorianCalendar)relativeDate.clone(); switch (m_units) { case DAYS: expiredDate.add(Calendar.DAY_OF_MONTH, -m_value); break; case MONTHS: expiredDate.add(Calendar.MONTH, -m_value); break; case YEARS: expiredDate.add(Calendar.YEAR, -m_value); break; default: // New value we forgot to add here? throw new AssertionError("Unknown RetentionUnits: " + m_units); } return expiredDate; }
java
public GregorianCalendar getExpiredDate(GregorianCalendar relativeDate) { // Get today's date and adjust by the specified age. GregorianCalendar expiredDate = (GregorianCalendar)relativeDate.clone(); switch (m_units) { case DAYS: expiredDate.add(Calendar.DAY_OF_MONTH, -m_value); break; case MONTHS: expiredDate.add(Calendar.MONTH, -m_value); break; case YEARS: expiredDate.add(Calendar.YEAR, -m_value); break; default: // New value we forgot to add here? throw new AssertionError("Unknown RetentionUnits: " + m_units); } return expiredDate; }
[ "public", "GregorianCalendar", "getExpiredDate", "(", "GregorianCalendar", "relativeDate", ")", "{", "// Get today's date and adjust by the specified age.\r", "GregorianCalendar", "expiredDate", "=", "(", "GregorianCalendar", ")", "relativeDate", ".", "clone", "(", ")", ";", "switch", "(", "m_units", ")", "{", "case", "DAYS", ":", "expiredDate", ".", "add", "(", "Calendar", ".", "DAY_OF_MONTH", ",", "-", "m_value", ")", ";", "break", ";", "case", "MONTHS", ":", "expiredDate", ".", "add", "(", "Calendar", ".", "MONTH", ",", "-", "m_value", ")", ";", "break", ";", "case", "YEARS", ":", "expiredDate", ".", "add", "(", "Calendar", ".", "YEAR", ",", "-", "m_value", ")", ";", "break", ";", "default", ":", "// New value we forgot to add here?\r", "throw", "new", "AssertionError", "(", "\"Unknown RetentionUnits: \"", "+", "m_units", ")", ";", "}", "return", "expiredDate", ";", "}" ]
Find the date on or before which objects expire based on the given date and the retention age specified in this object. The given date is cloned and then adjusted downward by the units and value in this RetentionAge. @param relativeDate Reference date. @return The date relative to the given one at which objects should be considered expired based on this RetentionAge.
[ "Find", "the", "date", "on", "or", "before", "which", "objects", "expire", "based", "on", "the", "given", "date", "and", "the", "retention", "age", "specified", "in", "this", "object", ".", "The", "given", "date", "is", "cloned", "and", "then", "adjusted", "downward", "by", "the", "units", "and", "value", "in", "this", "RetentionAge", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-common/src/main/java/com/dell/doradus/common/RetentionAge.java#L99-L117
138,084
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/cql/CQLStatementCache.java
CQLStatementCache.getPreparedQuery
public PreparedStatement getPreparedQuery(String tableName, Query query) { synchronized (m_prepQueryMap) { Map<Query, PreparedStatement> statementMap = m_prepQueryMap.get(tableName); if (statementMap == null) { statementMap = new HashMap<>(); m_prepQueryMap.put(tableName, statementMap); } PreparedStatement prepState = statementMap.get(query); if (prepState == null) { prepState = prepareQuery(tableName, query); statementMap.put(query, prepState); } return prepState; } }
java
public PreparedStatement getPreparedQuery(String tableName, Query query) { synchronized (m_prepQueryMap) { Map<Query, PreparedStatement> statementMap = m_prepQueryMap.get(tableName); if (statementMap == null) { statementMap = new HashMap<>(); m_prepQueryMap.put(tableName, statementMap); } PreparedStatement prepState = statementMap.get(query); if (prepState == null) { prepState = prepareQuery(tableName, query); statementMap.put(query, prepState); } return prepState; } }
[ "public", "PreparedStatement", "getPreparedQuery", "(", "String", "tableName", ",", "Query", "query", ")", "{", "synchronized", "(", "m_prepQueryMap", ")", "{", "Map", "<", "Query", ",", "PreparedStatement", ">", "statementMap", "=", "m_prepQueryMap", ".", "get", "(", "tableName", ")", ";", "if", "(", "statementMap", "==", "null", ")", "{", "statementMap", "=", "new", "HashMap", "<>", "(", ")", ";", "m_prepQueryMap", ".", "put", "(", "tableName", ",", "statementMap", ")", ";", "}", "PreparedStatement", "prepState", "=", "statementMap", ".", "get", "(", "query", ")", ";", "if", "(", "prepState", "==", "null", ")", "{", "prepState", "=", "prepareQuery", "(", "tableName", ",", "query", ")", ";", "statementMap", ".", "put", "(", "query", ",", "prepState", ")", ";", "}", "return", "prepState", ";", "}", "}" ]
Get the given prepared statement for the given table and query. Upon first invocation for a given combo, the query is parsed and cached. @param tableName Name of table to customize query for. @param query Inquiry {@link Query}. @return PreparedStatement for given combo.
[ "Get", "the", "given", "prepared", "statement", "for", "the", "given", "table", "and", "query", ".", "Upon", "first", "invocation", "for", "a", "given", "combo", "the", "query", "is", "parsed", "and", "cached", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/cql/CQLStatementCache.java#L91-L105
138,085
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/cql/CQLStatementCache.java
CQLStatementCache.getPreparedUpdate
public PreparedStatement getPreparedUpdate(String tableName, Update update) { synchronized (m_prepUpdateMap) { Map<Update, PreparedStatement> statementMap = m_prepUpdateMap.get(tableName); if (statementMap == null) { statementMap = new HashMap<>(); m_prepUpdateMap.put(tableName, statementMap); } PreparedStatement prepState = statementMap.get(update); if (prepState == null) { prepState = prepareUpdate(tableName, update); statementMap.put(update, prepState); } return prepState; } }
java
public PreparedStatement getPreparedUpdate(String tableName, Update update) { synchronized (m_prepUpdateMap) { Map<Update, PreparedStatement> statementMap = m_prepUpdateMap.get(tableName); if (statementMap == null) { statementMap = new HashMap<>(); m_prepUpdateMap.put(tableName, statementMap); } PreparedStatement prepState = statementMap.get(update); if (prepState == null) { prepState = prepareUpdate(tableName, update); statementMap.put(update, prepState); } return prepState; } }
[ "public", "PreparedStatement", "getPreparedUpdate", "(", "String", "tableName", ",", "Update", "update", ")", "{", "synchronized", "(", "m_prepUpdateMap", ")", "{", "Map", "<", "Update", ",", "PreparedStatement", ">", "statementMap", "=", "m_prepUpdateMap", ".", "get", "(", "tableName", ")", ";", "if", "(", "statementMap", "==", "null", ")", "{", "statementMap", "=", "new", "HashMap", "<>", "(", ")", ";", "m_prepUpdateMap", ".", "put", "(", "tableName", ",", "statementMap", ")", ";", "}", "PreparedStatement", "prepState", "=", "statementMap", ".", "get", "(", "update", ")", ";", "if", "(", "prepState", "==", "null", ")", "{", "prepState", "=", "prepareUpdate", "(", "tableName", ",", "update", ")", ";", "statementMap", ".", "put", "(", "update", ",", "prepState", ")", ";", "}", "return", "prepState", ";", "}", "}" ]
Get the given prepared statement for the given table and update. Upon first invocation for a given combo, the query is parsed and cached. @param tableName Name of table to customize update for. @param update Inquiry {@link Update}. @return PreparedStatement for given combo.
[ "Get", "the", "given", "prepared", "statement", "for", "the", "given", "table", "and", "update", ".", "Upon", "first", "invocation", "for", "a", "given", "combo", "the", "query", "is", "parsed", "and", "cached", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/cql/CQLStatementCache.java#L115-L129
138,086
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/Tenant.java
Tenant.getTenant
public static Tenant getTenant(ApplicationDefinition appDef) { String tenantName = appDef.getTenantName(); if (Utils.isEmpty(tenantName)) { return TenantService.instance().getDefaultTenant(); } TenantDefinition tenantDef = TenantService.instance().getTenantDefinition(tenantName); Utils.require(tenantDef != null, "Tenant definition does not exist: %s", tenantName); return new Tenant(tenantDef); }
java
public static Tenant getTenant(ApplicationDefinition appDef) { String tenantName = appDef.getTenantName(); if (Utils.isEmpty(tenantName)) { return TenantService.instance().getDefaultTenant(); } TenantDefinition tenantDef = TenantService.instance().getTenantDefinition(tenantName); Utils.require(tenantDef != null, "Tenant definition does not exist: %s", tenantName); return new Tenant(tenantDef); }
[ "public", "static", "Tenant", "getTenant", "(", "ApplicationDefinition", "appDef", ")", "{", "String", "tenantName", "=", "appDef", ".", "getTenantName", "(", ")", ";", "if", "(", "Utils", ".", "isEmpty", "(", "tenantName", ")", ")", "{", "return", "TenantService", ".", "instance", "(", ")", ".", "getDefaultTenant", "(", ")", ";", "}", "TenantDefinition", "tenantDef", "=", "TenantService", ".", "instance", "(", ")", ".", "getTenantDefinition", "(", "tenantName", ")", ";", "Utils", ".", "require", "(", "tenantDef", "!=", "null", ",", "\"Tenant definition does not exist: %s\"", ",", "tenantName", ")", ";", "return", "new", "Tenant", "(", "tenantDef", ")", ";", "}" ]
Create a Tenant object from the given application definition. If the application does not define a tenant, the Tenant for the default database is returned. @param appDef {@link ApplicationDefinition} @return {@link Tenant} in which application resides.
[ "Create", "a", "Tenant", "object", "from", "the", "given", "application", "definition", ".", "If", "the", "application", "does", "not", "define", "a", "tenant", "the", "Tenant", "for", "the", "default", "database", "is", "returned", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/Tenant.java#L43-L51
138,087
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/DBManagerService.java
DBManagerService.getDefaultDB
public DBService getDefaultDB() { String defaultTenantName = TenantService.instance().getDefaultTenantName(); synchronized (m_tenantDBMap) { DBService dbservice = m_tenantDBMap.get(defaultTenantName); assert dbservice != null : "Database for default tenant not found"; return dbservice; } }
java
public DBService getDefaultDB() { String defaultTenantName = TenantService.instance().getDefaultTenantName(); synchronized (m_tenantDBMap) { DBService dbservice = m_tenantDBMap.get(defaultTenantName); assert dbservice != null : "Database for default tenant not found"; return dbservice; } }
[ "public", "DBService", "getDefaultDB", "(", ")", "{", "String", "defaultTenantName", "=", "TenantService", ".", "instance", "(", ")", ".", "getDefaultTenantName", "(", ")", ";", "synchronized", "(", "m_tenantDBMap", ")", "{", "DBService", "dbservice", "=", "m_tenantDBMap", ".", "get", "(", "defaultTenantName", ")", ";", "assert", "dbservice", "!=", "null", ":", "\"Database for default tenant not found\"", ";", "return", "dbservice", ";", "}", "}" ]
Get the DBService for the default database. This object is created when the DBManagerService is started. @return {@link DBService} for the defaultdatabase.
[ "Get", "the", "DBService", "for", "the", "default", "database", ".", "This", "object", "is", "created", "when", "the", "DBManagerService", "is", "started", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/DBManagerService.java#L81-L88
138,088
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/DBManagerService.java
DBManagerService.getTenantDB
public DBService getTenantDB(Tenant tenant) { synchronized (m_tenantDBMap) { DBService dbservice = m_tenantDBMap.get(tenant.getName()); if (dbservice == null) { dbservice = createTenantDBService(tenant); m_tenantDBMap.put(tenant.getName(), dbservice); } else if (!sameTenantDefs(dbservice.getTenant().getDefinition(), tenant.getDefinition())) { m_logger.info("Purging obsolete DBService for redefined tenant: {}", tenant.getName()); dbservice.stop(); dbservice = createTenantDBService(tenant); m_tenantDBMap.put(tenant.getName(), dbservice); } return dbservice; } }
java
public DBService getTenantDB(Tenant tenant) { synchronized (m_tenantDBMap) { DBService dbservice = m_tenantDBMap.get(tenant.getName()); if (dbservice == null) { dbservice = createTenantDBService(tenant); m_tenantDBMap.put(tenant.getName(), dbservice); } else if (!sameTenantDefs(dbservice.getTenant().getDefinition(), tenant.getDefinition())) { m_logger.info("Purging obsolete DBService for redefined tenant: {}", tenant.getName()); dbservice.stop(); dbservice = createTenantDBService(tenant); m_tenantDBMap.put(tenant.getName(), dbservice); } return dbservice; } }
[ "public", "DBService", "getTenantDB", "(", "Tenant", "tenant", ")", "{", "synchronized", "(", "m_tenantDBMap", ")", "{", "DBService", "dbservice", "=", "m_tenantDBMap", ".", "get", "(", "tenant", ".", "getName", "(", ")", ")", ";", "if", "(", "dbservice", "==", "null", ")", "{", "dbservice", "=", "createTenantDBService", "(", "tenant", ")", ";", "m_tenantDBMap", ".", "put", "(", "tenant", ".", "getName", "(", ")", ",", "dbservice", ")", ";", "}", "else", "if", "(", "!", "sameTenantDefs", "(", "dbservice", ".", "getTenant", "(", ")", ".", "getDefinition", "(", ")", ",", "tenant", ".", "getDefinition", "(", ")", ")", ")", "{", "m_logger", ".", "info", "(", "\"Purging obsolete DBService for redefined tenant: {}\"", ",", "tenant", ".", "getName", "(", ")", ")", ";", "dbservice", ".", "stop", "(", ")", ";", "dbservice", "=", "createTenantDBService", "(", "tenant", ")", ";", "m_tenantDBMap", ".", "put", "(", "tenant", ".", "getName", "(", ")", ",", "dbservice", ")", ";", "}", "return", "dbservice", ";", "}", "}" ]
Get the DBService for the given tenant. The DBService is created if necessary, causing it to connect to its underlying DB. An exception is thrown if the DB cannot be connected. @param tenant {@link Tenant} to get DBService for. @return {@link DBService} that manages data for that tenant.
[ "Get", "the", "DBService", "for", "the", "given", "tenant", ".", "The", "DBService", "is", "created", "if", "necessary", "causing", "it", "to", "connect", "to", "its", "underlying", "DB", ".", "An", "exception", "is", "thrown", "if", "the", "DB", "cannot", "be", "connected", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/DBManagerService.java#L98-L112
138,089
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/DBManagerService.java
DBManagerService.updateTenantDef
public void updateTenantDef(TenantDefinition tenantDef) { synchronized (m_tenantDBMap) { DBService dbservice = m_tenantDBMap.get(tenantDef.getName()); if (dbservice != null) { Tenant updatedTenant = new Tenant(tenantDef); m_logger.info("Updating DBService for tenant: {}", updatedTenant.getName()); dbservice.updateTenant(updatedTenant); } } }
java
public void updateTenantDef(TenantDefinition tenantDef) { synchronized (m_tenantDBMap) { DBService dbservice = m_tenantDBMap.get(tenantDef.getName()); if (dbservice != null) { Tenant updatedTenant = new Tenant(tenantDef); m_logger.info("Updating DBService for tenant: {}", updatedTenant.getName()); dbservice.updateTenant(updatedTenant); } } }
[ "public", "void", "updateTenantDef", "(", "TenantDefinition", "tenantDef", ")", "{", "synchronized", "(", "m_tenantDBMap", ")", "{", "DBService", "dbservice", "=", "m_tenantDBMap", ".", "get", "(", "tenantDef", ".", "getName", "(", ")", ")", ";", "if", "(", "dbservice", "!=", "null", ")", "{", "Tenant", "updatedTenant", "=", "new", "Tenant", "(", "tenantDef", ")", ";", "m_logger", ".", "info", "(", "\"Updating DBService for tenant: {}\"", ",", "updatedTenant", ".", "getName", "(", ")", ")", ";", "dbservice", ".", "updateTenant", "(", "updatedTenant", ")", ";", "}", "}", "}" ]
Update the corresponding DBService with the given tenant definition. This method is called when an existing tenant is modified. If the DBService for the tenant has not yet been cached, this method is a no-op. Otherwise, the cached DBService is updated with the new tenant definition. @param tenantDef Updated {@link TenantDefinition}.
[ "Update", "the", "corresponding", "DBService", "with", "the", "given", "tenant", "definition", ".", "This", "method", "is", "called", "when", "an", "existing", "tenant", "is", "modified", ".", "If", "the", "DBService", "for", "the", "tenant", "has", "not", "yet", "been", "cached", "this", "method", "is", "a", "no", "-", "op", ".", "Otherwise", "the", "cached", "DBService", "is", "updated", "with", "the", "new", "tenant", "definition", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/DBManagerService.java#L122-L131
138,090
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/DBManagerService.java
DBManagerService.deleteTenantDB
public void deleteTenantDB(Tenant tenant) { synchronized (m_tenantDBMap) { DBService dbservice = m_tenantDBMap.remove(tenant.getName()); if (dbservice != null) { m_logger.info("Stopping DBService for deleted tenant: {}", tenant.getName()); dbservice.stop(); } } }
java
public void deleteTenantDB(Tenant tenant) { synchronized (m_tenantDBMap) { DBService dbservice = m_tenantDBMap.remove(tenant.getName()); if (dbservice != null) { m_logger.info("Stopping DBService for deleted tenant: {}", tenant.getName()); dbservice.stop(); } } }
[ "public", "void", "deleteTenantDB", "(", "Tenant", "tenant", ")", "{", "synchronized", "(", "m_tenantDBMap", ")", "{", "DBService", "dbservice", "=", "m_tenantDBMap", ".", "remove", "(", "tenant", ".", "getName", "(", ")", ")", ";", "if", "(", "dbservice", "!=", "null", ")", "{", "m_logger", ".", "info", "(", "\"Stopping DBService for deleted tenant: {}\"", ",", "tenant", ".", "getName", "(", ")", ")", ";", "dbservice", ".", "stop", "(", ")", ";", "}", "}", "}" ]
Close the DBService for the given tenant, if is has been cached. This is called when a tenant is deleted. @param tenant {@link Tenant} being deleted.
[ "Close", "the", "DBService", "for", "the", "given", "tenant", "if", "is", "has", "been", "cached", ".", "This", "is", "called", "when", "a", "tenant", "is", "deleted", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/DBManagerService.java#L139-L147
138,091
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/DBManagerService.java
DBManagerService.getActiveTenantInfo
public SortedMap<String, SortedMap<String, Object>> getActiveTenantInfo() { SortedMap<String, SortedMap<String, Object>> activeTenantMap = new TreeMap<>(); synchronized (m_tenantDBMap) { for (String tenantName : m_tenantDBMap.keySet()) { DBService dbservice = m_tenantDBMap.get(tenantName); Map<String, Object> dbServiceParams = dbservice.getAllParams(); activeTenantMap.put(tenantName, new TreeMap<String, Object>(dbServiceParams)); } } return activeTenantMap; }
java
public SortedMap<String, SortedMap<String, Object>> getActiveTenantInfo() { SortedMap<String, SortedMap<String, Object>> activeTenantMap = new TreeMap<>(); synchronized (m_tenantDBMap) { for (String tenantName : m_tenantDBMap.keySet()) { DBService dbservice = m_tenantDBMap.get(tenantName); Map<String, Object> dbServiceParams = dbservice.getAllParams(); activeTenantMap.put(tenantName, new TreeMap<String, Object>(dbServiceParams)); } } return activeTenantMap; }
[ "public", "SortedMap", "<", "String", ",", "SortedMap", "<", "String", ",", "Object", ">", ">", "getActiveTenantInfo", "(", ")", "{", "SortedMap", "<", "String", ",", "SortedMap", "<", "String", ",", "Object", ">", ">", "activeTenantMap", "=", "new", "TreeMap", "<>", "(", ")", ";", "synchronized", "(", "m_tenantDBMap", ")", "{", "for", "(", "String", "tenantName", ":", "m_tenantDBMap", ".", "keySet", "(", ")", ")", "{", "DBService", "dbservice", "=", "m_tenantDBMap", ".", "get", "(", "tenantName", ")", ";", "Map", "<", "String", ",", "Object", ">", "dbServiceParams", "=", "dbservice", ".", "getAllParams", "(", ")", ";", "activeTenantMap", ".", "put", "(", "tenantName", ",", "new", "TreeMap", "<", "String", ",", "Object", ">", "(", "dbServiceParams", ")", ")", ";", "}", "}", "return", "activeTenantMap", ";", "}" ]
Get the information about all active tenants, which are those whose DBService has been created. The is keyed by tenant name, and its value is a map of parameters configured for the corresponding DBService. @return Map of information for all active tenants.
[ "Get", "the", "information", "about", "all", "active", "tenants", "which", "are", "those", "whose", "DBService", "has", "been", "created", ".", "The", "is", "keyed", "by", "tenant", "name", "and", "its", "value", "is", "a", "map", "of", "parameters", "configured", "for", "the", "corresponding", "DBService", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/DBManagerService.java#L156-L166
138,092
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/DBManagerService.java
DBManagerService.createDefaultDBService
private DBService createDefaultDBService() { m_logger.info("Creating DBService for default tenant"); String dbServiceName = ServerParams.instance().getModuleParamString("DBService", "dbservice"); if (Utils.isEmpty(dbServiceName)) { throw new RuntimeException("'DBService.dbservice' parameter is not defined."); } DBService dbservice = null; Tenant defaultTenant = TenantService.instance().getDefaultTenant(); boolean bDBOpened = false; while (!bDBOpened) { try { // Find and call the constructor DBService(Tenant). @SuppressWarnings("unchecked") Class<DBService> serviceClass = (Class<DBService>) Class.forName(dbServiceName); Constructor<DBService> constructor = serviceClass.getConstructor(Tenant.class); dbservice = constructor.newInstance(defaultTenant); dbservice.initialize(); dbservice.start(); bDBOpened = true; } catch (IllegalArgumentException e) { throw new RuntimeException("Cannot load specified 'dbservice': " + dbServiceName, e); } catch (ClassNotFoundException e) { throw new RuntimeException("Could not load dbservice class '" + dbServiceName + "'", e); } catch (NoSuchMethodException e) { throw new RuntimeException("Required constructor missing for dbservice class: " + dbServiceName, e); } catch (SecurityException | InstantiationException | IllegalAccessException e) { throw new RuntimeException("Could not invoke constructor for dbservice class: " + dbServiceName, e); } catch (InvocationTargetException e) { // This is thrown when a constructor is invoked via reflection. if (!(e.getTargetException() instanceof DBNotAvailableException)) { throw new RuntimeException("Could not invoke constructor for dbservice class: " + dbServiceName, e); } } catch (DBNotAvailableException e) { // Fall through to retry. } catch (Throwable e) { throw new RuntimeException("Failed to initialize default DBService: " + dbServiceName, e); } if (!bDBOpened) { m_logger.info("Database is not reachable. Waiting to retry"); try { Thread.sleep(db_connect_retry_wait_millis); } catch (InterruptedException ex2) { // ignore } } } return dbservice; }
java
private DBService createDefaultDBService() { m_logger.info("Creating DBService for default tenant"); String dbServiceName = ServerParams.instance().getModuleParamString("DBService", "dbservice"); if (Utils.isEmpty(dbServiceName)) { throw new RuntimeException("'DBService.dbservice' parameter is not defined."); } DBService dbservice = null; Tenant defaultTenant = TenantService.instance().getDefaultTenant(); boolean bDBOpened = false; while (!bDBOpened) { try { // Find and call the constructor DBService(Tenant). @SuppressWarnings("unchecked") Class<DBService> serviceClass = (Class<DBService>) Class.forName(dbServiceName); Constructor<DBService> constructor = serviceClass.getConstructor(Tenant.class); dbservice = constructor.newInstance(defaultTenant); dbservice.initialize(); dbservice.start(); bDBOpened = true; } catch (IllegalArgumentException e) { throw new RuntimeException("Cannot load specified 'dbservice': " + dbServiceName, e); } catch (ClassNotFoundException e) { throw new RuntimeException("Could not load dbservice class '" + dbServiceName + "'", e); } catch (NoSuchMethodException e) { throw new RuntimeException("Required constructor missing for dbservice class: " + dbServiceName, e); } catch (SecurityException | InstantiationException | IllegalAccessException e) { throw new RuntimeException("Could not invoke constructor for dbservice class: " + dbServiceName, e); } catch (InvocationTargetException e) { // This is thrown when a constructor is invoked via reflection. if (!(e.getTargetException() instanceof DBNotAvailableException)) { throw new RuntimeException("Could not invoke constructor for dbservice class: " + dbServiceName, e); } } catch (DBNotAvailableException e) { // Fall through to retry. } catch (Throwable e) { throw new RuntimeException("Failed to initialize default DBService: " + dbServiceName, e); } if (!bDBOpened) { m_logger.info("Database is not reachable. Waiting to retry"); try { Thread.sleep(db_connect_retry_wait_millis); } catch (InterruptedException ex2) { // ignore } } } return dbservice; }
[ "private", "DBService", "createDefaultDBService", "(", ")", "{", "m_logger", ".", "info", "(", "\"Creating DBService for default tenant\"", ")", ";", "String", "dbServiceName", "=", "ServerParams", ".", "instance", "(", ")", ".", "getModuleParamString", "(", "\"DBService\"", ",", "\"dbservice\"", ")", ";", "if", "(", "Utils", ".", "isEmpty", "(", "dbServiceName", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"'DBService.dbservice' parameter is not defined.\"", ")", ";", "}", "DBService", "dbservice", "=", "null", ";", "Tenant", "defaultTenant", "=", "TenantService", ".", "instance", "(", ")", ".", "getDefaultTenant", "(", ")", ";", "boolean", "bDBOpened", "=", "false", ";", "while", "(", "!", "bDBOpened", ")", "{", "try", "{", "// Find and call the constructor DBService(Tenant).", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Class", "<", "DBService", ">", "serviceClass", "=", "(", "Class", "<", "DBService", ">", ")", "Class", ".", "forName", "(", "dbServiceName", ")", ";", "Constructor", "<", "DBService", ">", "constructor", "=", "serviceClass", ".", "getConstructor", "(", "Tenant", ".", "class", ")", ";", "dbservice", "=", "constructor", ".", "newInstance", "(", "defaultTenant", ")", ";", "dbservice", ".", "initialize", "(", ")", ";", "dbservice", ".", "start", "(", ")", ";", "bDBOpened", "=", "true", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Cannot load specified 'dbservice': \"", "+", "dbServiceName", ",", "e", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Could not load dbservice class '\"", "+", "dbServiceName", "+", "\"'\"", ",", "e", ")", ";", "}", "catch", "(", "NoSuchMethodException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Required constructor missing for dbservice class: \"", "+", "dbServiceName", ",", "e", ")", ";", "}", "catch", "(", "SecurityException", "|", "InstantiationException", "|", "IllegalAccessException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Could not invoke constructor for dbservice class: \"", "+", "dbServiceName", ",", "e", ")", ";", "}", "catch", "(", "InvocationTargetException", "e", ")", "{", "// This is thrown when a constructor is invoked via reflection.", "if", "(", "!", "(", "e", ".", "getTargetException", "(", ")", "instanceof", "DBNotAvailableException", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"Could not invoke constructor for dbservice class: \"", "+", "dbServiceName", ",", "e", ")", ";", "}", "}", "catch", "(", "DBNotAvailableException", "e", ")", "{", "// Fall through to retry.", "}", "catch", "(", "Throwable", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Failed to initialize default DBService: \"", "+", "dbServiceName", ",", "e", ")", ";", "}", "if", "(", "!", "bDBOpened", ")", "{", "m_logger", ".", "info", "(", "\"Database is not reachable. Waiting to retry\"", ")", ";", "try", "{", "Thread", ".", "sleep", "(", "db_connect_retry_wait_millis", ")", ";", "}", "catch", "(", "InterruptedException", "ex2", ")", "{", "// ignore", "}", "}", "}", "return", "dbservice", ";", "}" ]
throws a DBNotAvailableException, keep trying.
[ "throws", "a", "DBNotAvailableException", "keep", "trying", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/DBManagerService.java#L172-L221
138,093
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/DBManagerService.java
DBManagerService.createTenantDBService
private DBService createTenantDBService(Tenant tenant) { m_logger.info("Creating DBService for tenant: {}", tenant.getName()); Map<String, Object> dbServiceParams = tenant.getDefinition().getOptionMap("DBService"); String dbServiceName = null; if (dbServiceParams == null || !dbServiceParams.containsKey("dbservice")) { dbServiceName = ServerParams.instance().getModuleParamString("DBService", "dbservice"); Utils.require(!Utils.isEmpty(dbServiceName), "DBService.dbservice parameter is not defined"); } else { dbServiceName = dbServiceParams.get("dbservice").toString(); } DBService dbservice = null; try { @SuppressWarnings("unchecked") Class<DBService> serviceClass = (Class<DBService>) Class.forName(dbServiceName); Constructor<DBService> constructor = serviceClass.getConstructor(Tenant.class); dbservice = constructor.newInstance(tenant); dbservice.initialize(); dbservice.start(); } catch (IllegalArgumentException e) { throw new RuntimeException("Cannot load specified 'dbservice': " + dbServiceName, e); } catch (ClassNotFoundException e) { throw new RuntimeException("Could not load dbservice class '" + dbServiceName + "'", e); } catch (NoSuchMethodException e) { throw new RuntimeException("Required constructor missing for dbservice class: " + dbServiceName, e); } catch (SecurityException | InstantiationException | IllegalAccessException | InvocationTargetException e) { throw new RuntimeException("Could not invoke constructor for dbservice class: " + dbServiceName, e); } catch (Throwable e) { throw new RuntimeException("Failed to initialize DBService '" + dbServiceName + "' for tenant: " + tenant.getName(), e); } return dbservice; }
java
private DBService createTenantDBService(Tenant tenant) { m_logger.info("Creating DBService for tenant: {}", tenant.getName()); Map<String, Object> dbServiceParams = tenant.getDefinition().getOptionMap("DBService"); String dbServiceName = null; if (dbServiceParams == null || !dbServiceParams.containsKey("dbservice")) { dbServiceName = ServerParams.instance().getModuleParamString("DBService", "dbservice"); Utils.require(!Utils.isEmpty(dbServiceName), "DBService.dbservice parameter is not defined"); } else { dbServiceName = dbServiceParams.get("dbservice").toString(); } DBService dbservice = null; try { @SuppressWarnings("unchecked") Class<DBService> serviceClass = (Class<DBService>) Class.forName(dbServiceName); Constructor<DBService> constructor = serviceClass.getConstructor(Tenant.class); dbservice = constructor.newInstance(tenant); dbservice.initialize(); dbservice.start(); } catch (IllegalArgumentException e) { throw new RuntimeException("Cannot load specified 'dbservice': " + dbServiceName, e); } catch (ClassNotFoundException e) { throw new RuntimeException("Could not load dbservice class '" + dbServiceName + "'", e); } catch (NoSuchMethodException e) { throw new RuntimeException("Required constructor missing for dbservice class: " + dbServiceName, e); } catch (SecurityException | InstantiationException | IllegalAccessException | InvocationTargetException e) { throw new RuntimeException("Could not invoke constructor for dbservice class: " + dbServiceName, e); } catch (Throwable e) { throw new RuntimeException("Failed to initialize DBService '" + dbServiceName + "' for tenant: " + tenant.getName(), e); } return dbservice; }
[ "private", "DBService", "createTenantDBService", "(", "Tenant", "tenant", ")", "{", "m_logger", ".", "info", "(", "\"Creating DBService for tenant: {}\"", ",", "tenant", ".", "getName", "(", ")", ")", ";", "Map", "<", "String", ",", "Object", ">", "dbServiceParams", "=", "tenant", ".", "getDefinition", "(", ")", ".", "getOptionMap", "(", "\"DBService\"", ")", ";", "String", "dbServiceName", "=", "null", ";", "if", "(", "dbServiceParams", "==", "null", "||", "!", "dbServiceParams", ".", "containsKey", "(", "\"dbservice\"", ")", ")", "{", "dbServiceName", "=", "ServerParams", ".", "instance", "(", ")", ".", "getModuleParamString", "(", "\"DBService\"", ",", "\"dbservice\"", ")", ";", "Utils", ".", "require", "(", "!", "Utils", ".", "isEmpty", "(", "dbServiceName", ")", ",", "\"DBService.dbservice parameter is not defined\"", ")", ";", "}", "else", "{", "dbServiceName", "=", "dbServiceParams", ".", "get", "(", "\"dbservice\"", ")", ".", "toString", "(", ")", ";", "}", "DBService", "dbservice", "=", "null", ";", "try", "{", "@", "SuppressWarnings", "(", "\"unchecked\"", ")", "Class", "<", "DBService", ">", "serviceClass", "=", "(", "Class", "<", "DBService", ">", ")", "Class", ".", "forName", "(", "dbServiceName", ")", ";", "Constructor", "<", "DBService", ">", "constructor", "=", "serviceClass", ".", "getConstructor", "(", "Tenant", ".", "class", ")", ";", "dbservice", "=", "constructor", ".", "newInstance", "(", "tenant", ")", ";", "dbservice", ".", "initialize", "(", ")", ";", "dbservice", ".", "start", "(", ")", ";", "}", "catch", "(", "IllegalArgumentException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Cannot load specified 'dbservice': \"", "+", "dbServiceName", ",", "e", ")", ";", "}", "catch", "(", "ClassNotFoundException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Could not load dbservice class '\"", "+", "dbServiceName", "+", "\"'\"", ",", "e", ")", ";", "}", "catch", "(", "NoSuchMethodException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Required constructor missing for dbservice class: \"", "+", "dbServiceName", ",", "e", ")", ";", "}", "catch", "(", "SecurityException", "|", "InstantiationException", "|", "IllegalAccessException", "|", "InvocationTargetException", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Could not invoke constructor for dbservice class: \"", "+", "dbServiceName", ",", "e", ")", ";", "}", "catch", "(", "Throwable", "e", ")", "{", "throw", "new", "RuntimeException", "(", "\"Failed to initialize DBService '\"", "+", "dbServiceName", "+", "\"' for tenant: \"", "+", "tenant", ".", "getName", "(", ")", ",", "e", ")", ";", "}", "return", "dbservice", ";", "}" ]
Create a new DBService for the given tenant.
[ "Create", "a", "new", "DBService", "for", "the", "given", "tenant", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/DBManagerService.java#L224-L256
138,094
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/DBManagerService.java
DBManagerService.sameTenantDefs
private static boolean sameTenantDefs(TenantDefinition tenantDef1, TenantDefinition tenantDef2) { return isEqual(tenantDef1.getProperty(TenantService.CREATED_ON_PROP), tenantDef2.getProperty(TenantService.CREATED_ON_PROP)) && isEqual(tenantDef1.getProperty(TenantService.CREATED_ON_PROP), tenantDef2.getProperty(TenantService.CREATED_ON_PROP)); }
java
private static boolean sameTenantDefs(TenantDefinition tenantDef1, TenantDefinition tenantDef2) { return isEqual(tenantDef1.getProperty(TenantService.CREATED_ON_PROP), tenantDef2.getProperty(TenantService.CREATED_ON_PROP)) && isEqual(tenantDef1.getProperty(TenantService.CREATED_ON_PROP), tenantDef2.getProperty(TenantService.CREATED_ON_PROP)); }
[ "private", "static", "boolean", "sameTenantDefs", "(", "TenantDefinition", "tenantDef1", ",", "TenantDefinition", "tenantDef2", ")", "{", "return", "isEqual", "(", "tenantDef1", ".", "getProperty", "(", "TenantService", ".", "CREATED_ON_PROP", ")", ",", "tenantDef2", ".", "getProperty", "(", "TenantService", ".", "CREATED_ON_PROP", ")", ")", "&&", "isEqual", "(", "tenantDef1", ".", "getProperty", "(", "TenantService", ".", "CREATED_ON_PROP", ")", ",", "tenantDef2", ".", "getProperty", "(", "TenantService", ".", "CREATED_ON_PROP", ")", ")", ";", "}" ]
stamps, allowing for either property to be null for older definitions.
[ "stamps", "allowing", "for", "either", "property", "to", "be", "null", "for", "older", "definitions", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/DBManagerService.java#L260-L265
138,095
QSFT/Doradus
doradus-server/src/main/java/com/dell/doradus/service/db/DBManagerService.java
DBManagerService.isEqual
private static boolean isEqual(String string1, String string2) { return (string1 == null && string2 == null) || (string1 != null && string1.equals(string2)); }
java
private static boolean isEqual(String string1, String string2) { return (string1 == null && string2 == null) || (string1 != null && string1.equals(string2)); }
[ "private", "static", "boolean", "isEqual", "(", "String", "string1", ",", "String", "string2", ")", "{", "return", "(", "string1", "==", "null", "&&", "string2", "==", "null", ")", "||", "(", "string1", "!=", "null", "&&", "string1", ".", "equals", "(", "string2", ")", ")", ";", "}" ]
Both strings are null or equal.
[ "Both", "strings", "are", "null", "or", "equal", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-server/src/main/java/com/dell/doradus/service/db/DBManagerService.java#L268-L270
138,096
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java
CSVLoader.createApplication
private void createApplication() { String schema = getSchema(); ContentType contentType = null; if (m_config.schema.toLowerCase().endsWith(".json")) { contentType = ContentType.APPLICATION_JSON; } else if (m_config.schema.toLowerCase().endsWith(".xml")) { contentType = ContentType.TEXT_XML; } else { logErrorThrow("Unknown file type for schema: {}", m_config.schema); } try { m_logger.info("Creating application '{}' with schema: {}", m_config.app, m_config.schema); m_client.createApplication(schema, contentType); } catch (Exception e) { logErrorThrow("Error creating schema: {}", e); } try { m_session = m_client.openApplication(m_config.app); } catch (RuntimeException e) { logErrorThrow("Application '{}' not found after creation: {}.", m_config.app, e.toString()); } String ss = m_session.getAppDef().getStorageService(); if (!Utils.isEmpty(ss) && ss.startsWith("OLAP")) { m_bOLAPApp = true; } loadTables(); }
java
private void createApplication() { String schema = getSchema(); ContentType contentType = null; if (m_config.schema.toLowerCase().endsWith(".json")) { contentType = ContentType.APPLICATION_JSON; } else if (m_config.schema.toLowerCase().endsWith(".xml")) { contentType = ContentType.TEXT_XML; } else { logErrorThrow("Unknown file type for schema: {}", m_config.schema); } try { m_logger.info("Creating application '{}' with schema: {}", m_config.app, m_config.schema); m_client.createApplication(schema, contentType); } catch (Exception e) { logErrorThrow("Error creating schema: {}", e); } try { m_session = m_client.openApplication(m_config.app); } catch (RuntimeException e) { logErrorThrow("Application '{}' not found after creation: {}.", m_config.app, e.toString()); } String ss = m_session.getAppDef().getStorageService(); if (!Utils.isEmpty(ss) && ss.startsWith("OLAP")) { m_bOLAPApp = true; } loadTables(); }
[ "private", "void", "createApplication", "(", ")", "{", "String", "schema", "=", "getSchema", "(", ")", ";", "ContentType", "contentType", "=", "null", ";", "if", "(", "m_config", ".", "schema", ".", "toLowerCase", "(", ")", ".", "endsWith", "(", "\".json\"", ")", ")", "{", "contentType", "=", "ContentType", ".", "APPLICATION_JSON", ";", "}", "else", "if", "(", "m_config", ".", "schema", ".", "toLowerCase", "(", ")", ".", "endsWith", "(", "\".xml\"", ")", ")", "{", "contentType", "=", "ContentType", ".", "TEXT_XML", ";", "}", "else", "{", "logErrorThrow", "(", "\"Unknown file type for schema: {}\"", ",", "m_config", ".", "schema", ")", ";", "}", "try", "{", "m_logger", ".", "info", "(", "\"Creating application '{}' with schema: {}\"", ",", "m_config", ".", "app", ",", "m_config", ".", "schema", ")", ";", "m_client", ".", "createApplication", "(", "schema", ",", "contentType", ")", ";", "}", "catch", "(", "Exception", "e", ")", "{", "logErrorThrow", "(", "\"Error creating schema: {}\"", ",", "e", ")", ";", "}", "try", "{", "m_session", "=", "m_client", ".", "openApplication", "(", "m_config", ".", "app", ")", ";", "}", "catch", "(", "RuntimeException", "e", ")", "{", "logErrorThrow", "(", "\"Application '{}' not found after creation: {}.\"", ",", "m_config", ".", "app", ",", "e", ".", "toString", "(", ")", ")", ";", "}", "String", "ss", "=", "m_session", ".", "getAppDef", "(", ")", ".", "getStorageService", "(", ")", ";", "if", "(", "!", "Utils", ".", "isEmpty", "(", "ss", ")", "&&", "ss", ".", "startsWith", "(", "\"OLAP\"", ")", ")", "{", "m_bOLAPApp", "=", "true", ";", "}", "loadTables", "(", ")", ";", "}" ]
Create the application from the configured schema file name.
[ "Create", "the", "application", "from", "the", "configured", "schema", "file", "name", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java#L244-L272
138,097
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java
CSVLoader.deleteApplication
private void deleteApplication() { ApplicationDefinition appDef = m_client.getAppDef(m_config.app); if (appDef != null) { m_logger.info("Deleting existing application: {}", appDef.getAppName()); m_client.deleteApplication(appDef.getAppName(), appDef.getKey()); } }
java
private void deleteApplication() { ApplicationDefinition appDef = m_client.getAppDef(m_config.app); if (appDef != null) { m_logger.info("Deleting existing application: {}", appDef.getAppName()); m_client.deleteApplication(appDef.getAppName(), appDef.getKey()); } }
[ "private", "void", "deleteApplication", "(", ")", "{", "ApplicationDefinition", "appDef", "=", "m_client", ".", "getAppDef", "(", "m_config", ".", "app", ")", ";", "if", "(", "appDef", "!=", "null", ")", "{", "m_logger", ".", "info", "(", "\"Deleting existing application: {}\"", ",", "appDef", ".", "getAppName", "(", ")", ")", ";", "m_client", ".", "deleteApplication", "(", "appDef", ".", "getAppName", "(", ")", ",", "appDef", ".", "getKey", "(", ")", ")", ";", "}", "}" ]
Delete existing application if it exists.
[ "Delete", "existing", "application", "if", "it", "exists", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java#L275-L281
138,098
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java
CSVLoader.determineTableFromFileName
private TableDefinition determineTableFromFileName(String fileName) { ApplicationDefinition appDef = m_session.getAppDef(); for (String tableName : m_tableNameList) { if (fileName.regionMatches(true, 0, tableName, 0, tableName.length())) { return appDef.getTableDef(tableName); } } return null; }
java
private TableDefinition determineTableFromFileName(String fileName) { ApplicationDefinition appDef = m_session.getAppDef(); for (String tableName : m_tableNameList) { if (fileName.regionMatches(true, 0, tableName, 0, tableName.length())) { return appDef.getTableDef(tableName); } } return null; }
[ "private", "TableDefinition", "determineTableFromFileName", "(", "String", "fileName", ")", "{", "ApplicationDefinition", "appDef", "=", "m_session", ".", "getAppDef", "(", ")", ";", "for", "(", "String", "tableName", ":", "m_tableNameList", ")", "{", "if", "(", "fileName", ".", "regionMatches", "(", "true", ",", "0", ",", "tableName", ",", "0", ",", "tableName", ".", "length", "(", ")", ")", ")", "{", "return", "appDef", ".", "getTableDef", "(", "tableName", ")", ";", "}", "}", "return", "null", ";", "}" ]
table name that matches the starting characters of the CSV file name.
[ "table", "name", "that", "matches", "the", "starting", "characters", "of", "the", "CSV", "file", "name", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java#L285-L293
138,099
QSFT/Doradus
doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java
CSVLoader.getFieldListFromHeader
private List<String> getFieldListFromHeader(BufferedReader reader) { // Read the first line and watch out for BOM at the front of the header. String header = null; try { header = reader.readLine(); } catch (IOException e) { // Leave header null } if (Utils.isEmpty(header)) { logErrorThrow("No header found in file"); } if (header.charAt(0) == '\uFEFF') { header = header.substring(1); } // Split around commas, though this will include spaces. String[] tokens = header.split(","); List<String> result = new ArrayList<String>(); for (String token : tokens) { // If this field matches the _ID field, add it with that name. String fieldName = token.trim(); if (fieldName.equals(m_config.id)) { result.add(CommonDefs.ID_FIELD); } else { result.add(token.trim()); } } return result; }
java
private List<String> getFieldListFromHeader(BufferedReader reader) { // Read the first line and watch out for BOM at the front of the header. String header = null; try { header = reader.readLine(); } catch (IOException e) { // Leave header null } if (Utils.isEmpty(header)) { logErrorThrow("No header found in file"); } if (header.charAt(0) == '\uFEFF') { header = header.substring(1); } // Split around commas, though this will include spaces. String[] tokens = header.split(","); List<String> result = new ArrayList<String>(); for (String token : tokens) { // If this field matches the _ID field, add it with that name. String fieldName = token.trim(); if (fieldName.equals(m_config.id)) { result.add(CommonDefs.ID_FIELD); } else { result.add(token.trim()); } } return result; }
[ "private", "List", "<", "String", ">", "getFieldListFromHeader", "(", "BufferedReader", "reader", ")", "{", "// Read the first line and watch out for BOM at the front of the header.\r", "String", "header", "=", "null", ";", "try", "{", "header", "=", "reader", ".", "readLine", "(", ")", ";", "}", "catch", "(", "IOException", "e", ")", "{", "// Leave header null\r", "}", "if", "(", "Utils", ".", "isEmpty", "(", "header", ")", ")", "{", "logErrorThrow", "(", "\"No header found in file\"", ")", ";", "}", "if", "(", "header", ".", "charAt", "(", "0", ")", "==", "'", "'", ")", "{", "header", "=", "header", ".", "substring", "(", "1", ")", ";", "}", "// Split around commas, though this will include spaces.\r", "String", "[", "]", "tokens", "=", "header", ".", "split", "(", "\",\"", ")", ";", "List", "<", "String", ">", "result", "=", "new", "ArrayList", "<", "String", ">", "(", ")", ";", "for", "(", "String", "token", ":", "tokens", ")", "{", "// If this field matches the _ID field, add it with that name.\r", "String", "fieldName", "=", "token", ".", "trim", "(", ")", ";", "if", "(", "fieldName", ".", "equals", "(", "m_config", ".", "id", ")", ")", "{", "result", ".", "add", "(", "CommonDefs", ".", "ID_FIELD", ")", ";", "}", "else", "{", "result", ".", "add", "(", "token", ".", "trim", "(", ")", ")", ";", "}", "}", "return", "result", ";", "}" ]
Extract the field names from the given CSV header line and return as a list.
[ "Extract", "the", "field", "names", "from", "the", "given", "CSV", "header", "line", "and", "return", "as", "a", "list", "." ]
ad64d3c37922eefda68ec8869ef089c1ca604b70
https://github.com/QSFT/Doradus/blob/ad64d3c37922eefda68ec8869ef089c1ca604b70/doradus-client/src/main/java/com/dell/doradus/client/utils/CSVLoader.java#L301-L329