repo stringlengths 7 58 | path stringlengths 12 218 | func_name stringlengths 3 140 | original_string stringlengths 73 34.1k | language stringclasses 1
value | code stringlengths 73 34.1k | code_tokens list | docstring stringlengths 3 16k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 105 339 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
baratine/baratine | framework/src/main/java/com/caucho/v5/bartender/heartbeat/HeartbeatImpl.java | HeartbeatImpl.updateHubHeartbeatSelf | private void updateHubHeartbeatSelf()
{
_isHubHeartbeatSelf = true;
if (_hubHeartbeatCount < 2) {
for (Result<Boolean> result : _hubHeartbeatList) {
result.ok(true);
}
_hubHeartbeatList.clear();
}
} | java | private void updateHubHeartbeatSelf()
{
_isHubHeartbeatSelf = true;
if (_hubHeartbeatCount < 2) {
for (Result<Boolean> result : _hubHeartbeatList) {
result.ok(true);
}
_hubHeartbeatList.clear();
}
} | [
"private",
"void",
"updateHubHeartbeatSelf",
"(",
")",
"{",
"_isHubHeartbeatSelf",
"=",
"true",
";",
"if",
"(",
"_hubHeartbeatCount",
"<",
"2",
")",
"{",
"for",
"(",
"Result",
"<",
"Boolean",
">",
"result",
":",
"_hubHeartbeatList",
")",
"{",
"result",
".",
... | If the join is to the self server, and there's only one successful
join, update immediately. | [
"If",
"the",
"join",
"is",
"to",
"the",
"self",
"server",
"and",
"there",
"s",
"only",
"one",
"successful",
"join",
"update",
"immediately",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/bartender/heartbeat/HeartbeatImpl.java#L638-L649 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/bartender/heartbeat/HeartbeatImpl.java | HeartbeatImpl.updateRack | void updateRack(UpdateRackHeartbeat updateRack)
{
ClusterHeartbeat cluster = findCluster(updateRack.getClusterId());
if (cluster == null) {
return;
}
RackHeartbeat rack;
if (cluster != _serverSelf.getCluster()) {
rack = cluster.createRack("external");
ClusterTarget target = createClusterTarget(cluster);
}
else {
rack = cluster.findRack(updateRack.getId());
}
if (rack == null) {
return;
}
rack.updateRack(this, updateRack);
updateHeartbeats();
} | java | void updateRack(UpdateRackHeartbeat updateRack)
{
ClusterHeartbeat cluster = findCluster(updateRack.getClusterId());
if (cluster == null) {
return;
}
RackHeartbeat rack;
if (cluster != _serverSelf.getCluster()) {
rack = cluster.createRack("external");
ClusterTarget target = createClusterTarget(cluster);
}
else {
rack = cluster.findRack(updateRack.getId());
}
if (rack == null) {
return;
}
rack.updateRack(this, updateRack);
updateHeartbeats();
} | [
"void",
"updateRack",
"(",
"UpdateRackHeartbeat",
"updateRack",
")",
"{",
"ClusterHeartbeat",
"cluster",
"=",
"findCluster",
"(",
"updateRack",
".",
"getClusterId",
"(",
")",
")",
";",
"if",
"(",
"cluster",
"==",
"null",
")",
"{",
"return",
";",
"}",
"RackHe... | Process an update message for a rack of servers. | [
"Process",
"an",
"update",
"message",
"for",
"a",
"rack",
"of",
"servers",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/bartender/heartbeat/HeartbeatImpl.java#L655-L680 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/bartender/heartbeat/HeartbeatImpl.java | HeartbeatImpl.updateServerStart | private void updateServerStart(UpdateServerHeartbeat update)
{
// internal communication is non-ssl
boolean isSSL = false;
ServerHeartbeat server = _root.createServer(update.getAddress(),
update.getPort(),
isSSL,
0,
getCluster());
server.setDisplayName(update.getDisplayName());
//server.setMachineHash(serverUpdate.getMachineHash());
updateServer(server, update);
if (server.getRack() != null) {
server.getRack().update();
}
} | java | private void updateServerStart(UpdateServerHeartbeat update)
{
// internal communication is non-ssl
boolean isSSL = false;
ServerHeartbeat server = _root.createServer(update.getAddress(),
update.getPort(),
isSSL,
0,
getCluster());
server.setDisplayName(update.getDisplayName());
//server.setMachineHash(serverUpdate.getMachineHash());
updateServer(server, update);
if (server.getRack() != null) {
server.getRack().update();
}
} | [
"private",
"void",
"updateServerStart",
"(",
"UpdateServerHeartbeat",
"update",
")",
"{",
"// internal communication is non-ssl",
"boolean",
"isSSL",
"=",
"false",
";",
"ServerHeartbeat",
"server",
"=",
"_root",
".",
"createServer",
"(",
"update",
".",
"getAddress",
"... | Update a server where the update is directly from the peer. | [
"Update",
"a",
"server",
"where",
"the",
"update",
"is",
"directly",
"from",
"the",
"peer",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/bartender/heartbeat/HeartbeatImpl.java#L685-L704 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/bartender/heartbeat/HeartbeatImpl.java | HeartbeatImpl.updateServer | void updateServer(ServerHeartbeat server, UpdateServerHeartbeat update)
{
if (server.isSelf()) {
return;
}
String externalId = update.getExternalId();
updateExternal(server, externalId);
// XXX: validation
server.setSeedIndex(update.getSeedIndex());
if (server.onHeartbeatUpdate(update)) {
if (server.isUp()) {
onServerStart(server);
}
else {
onServerStop(server);
}
}
} | java | void updateServer(ServerHeartbeat server, UpdateServerHeartbeat update)
{
if (server.isSelf()) {
return;
}
String externalId = update.getExternalId();
updateExternal(server, externalId);
// XXX: validation
server.setSeedIndex(update.getSeedIndex());
if (server.onHeartbeatUpdate(update)) {
if (server.isUp()) {
onServerStart(server);
}
else {
onServerStop(server);
}
}
} | [
"void",
"updateServer",
"(",
"ServerHeartbeat",
"server",
",",
"UpdateServerHeartbeat",
"update",
")",
"{",
"if",
"(",
"server",
".",
"isSelf",
"(",
")",
")",
"{",
"return",
";",
"}",
"String",
"externalId",
"=",
"update",
".",
"getExternalId",
"(",
")",
"... | Update a server with a heartbeat update.
@param server the server to be updated
@param update the new update information | [
"Update",
"a",
"server",
"with",
"a",
"heartbeat",
"update",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/bartender/heartbeat/HeartbeatImpl.java#L712-L733 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/bartender/heartbeat/HeartbeatImpl.java | HeartbeatImpl.updateExternal | private void updateExternal(ServerHeartbeat server, String externalId)
{
if (externalId != null) {
ServerHeartbeat serverExternal = _root.getServer(externalId);
server.setExternalServer(serverExternal);
}
else {
server.setExternalServer(null);
/*
if (serverExternal != null) {
serverExternal.setDelegate(data);
_root.updateSequence();
}
*/
}
// data.setExternalId(externalId);
} | java | private void updateExternal(ServerHeartbeat server, String externalId)
{
if (externalId != null) {
ServerHeartbeat serverExternal = _root.getServer(externalId);
server.setExternalServer(serverExternal);
}
else {
server.setExternalServer(null);
/*
if (serverExternal != null) {
serverExternal.setDelegate(data);
_root.updateSequence();
}
*/
}
// data.setExternalId(externalId);
} | [
"private",
"void",
"updateExternal",
"(",
"ServerHeartbeat",
"server",
",",
"String",
"externalId",
")",
"{",
"if",
"(",
"externalId",
"!=",
"null",
")",
"{",
"ServerHeartbeat",
"serverExternal",
"=",
"_root",
".",
"getServer",
"(",
"externalId",
")",
";",
"se... | Update the external server delegation.
Cloud static IPs might be routing IPs that aren't local interfaces. In
that case, the routing assignment to the dynamic IP must be passed along
with the heartbeat. | [
"Update",
"the",
"external",
"server",
"delegation",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/bartender/heartbeat/HeartbeatImpl.java#L742-L761 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/bartender/heartbeat/HeartbeatImpl.java | HeartbeatImpl.onServerLinkClose | private void onServerLinkClose(String hostName)
{
ServerHeartbeat server = _root.getServer(hostName);
if (server == null) {
return;
}
if (! isHub(server) && ! isHub(_serverSelf)) {
return;
}
if (server.onHeartbeatStop()) {
onServerStop(server);
if (server.getRack() != null) {
server.getRack().update();
}
updateHeartbeats();
}
} | java | private void onServerLinkClose(String hostName)
{
ServerHeartbeat server = _root.getServer(hostName);
if (server == null) {
return;
}
if (! isHub(server) && ! isHub(_serverSelf)) {
return;
}
if (server.onHeartbeatStop()) {
onServerStop(server);
if (server.getRack() != null) {
server.getRack().update();
}
updateHeartbeats();
}
} | [
"private",
"void",
"onServerLinkClose",
"(",
"String",
"hostName",
")",
"{",
"ServerHeartbeat",
"server",
"=",
"_root",
".",
"getServer",
"(",
"hostName",
")",
";",
"if",
"(",
"server",
"==",
"null",
")",
"{",
"return",
";",
"}",
"if",
"(",
"!",
"isHub",... | The peer server is now down. | [
"The",
"peer",
"server",
"is",
"now",
"down",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/bartender/heartbeat/HeartbeatImpl.java#L805-L826 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/bartender/heartbeat/HeartbeatImpl.java | HeartbeatImpl.isHub | private boolean isHub(ServerBartender server)
{
int upCount = 0;
for (ServerHeartbeat rackServer : _rack.getServers()) {
if (rackServer == null || ! rackServer.isUp()) {
continue;
}
if (rackServer == server && upCount < _hubCount) {
return true;
}
upCount++;
if (_hubCount <= upCount) {
return false;
}
}
return false;
} | java | private boolean isHub(ServerBartender server)
{
int upCount = 0;
for (ServerHeartbeat rackServer : _rack.getServers()) {
if (rackServer == null || ! rackServer.isUp()) {
continue;
}
if (rackServer == server && upCount < _hubCount) {
return true;
}
upCount++;
if (_hubCount <= upCount) {
return false;
}
}
return false;
} | [
"private",
"boolean",
"isHub",
"(",
"ServerBartender",
"server",
")",
"{",
"int",
"upCount",
"=",
"0",
";",
"for",
"(",
"ServerHeartbeat",
"rackServer",
":",
"_rack",
".",
"getServers",
"(",
")",
")",
"{",
"if",
"(",
"rackServer",
"==",
"null",
"||",
"!"... | Test if the server is a hub server for its rack.
The hub are the first few active servers, where the servers are sorted by
IP address and port. The default hub count is 3. | [
"Test",
"if",
"the",
"server",
"is",
"a",
"hub",
"server",
"for",
"its",
"rack",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/bartender/heartbeat/HeartbeatImpl.java#L979-L1000 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/bartender/heartbeat/HeartbeatImpl.java | HeartbeatImpl.sendHubHeartbeats | private void sendHubHeartbeats()
{
RackHeartbeat rack = _rack;
UpdateRackHeartbeat updateRack = rack.getUpdate();
UpdatePodSystem updatePod = getUpdatePodSystem();
long now = CurrentTime.currentTime();
if (! isJoinComplete()) {
updatePod = null;
}
// send hub update to all servers in the rack
for (ServerHeartbeat rackServer : _rack.getServers()) {
if (rackServer == null || rackServer == _serverSelf) {
continue;
}
ServerTarget target = createTargetServer(rackServer);
target.hubHeartbeat(getServerSelf().getUpdate(),
updateRack,
updatePod,
now);
}
} | java | private void sendHubHeartbeats()
{
RackHeartbeat rack = _rack;
UpdateRackHeartbeat updateRack = rack.getUpdate();
UpdatePodSystem updatePod = getUpdatePodSystem();
long now = CurrentTime.currentTime();
if (! isJoinComplete()) {
updatePod = null;
}
// send hub update to all servers in the rack
for (ServerHeartbeat rackServer : _rack.getServers()) {
if (rackServer == null || rackServer == _serverSelf) {
continue;
}
ServerTarget target = createTargetServer(rackServer);
target.hubHeartbeat(getServerSelf().getUpdate(),
updateRack,
updatePod,
now);
}
} | [
"private",
"void",
"sendHubHeartbeats",
"(",
")",
"{",
"RackHeartbeat",
"rack",
"=",
"_rack",
";",
"UpdateRackHeartbeat",
"updateRack",
"=",
"rack",
".",
"getUpdate",
"(",
")",
";",
"UpdatePodSystem",
"updatePod",
"=",
"getUpdatePodSystem",
"(",
")",
";",
"long"... | Sends full heartbeat messages to all targets. Hub heartbeat messages
contains all the servers in the hub and all the pods known to the hub
server.
@param type | [
"Sends",
"full",
"heartbeat",
"messages",
"to",
"all",
"targets",
".",
"Hub",
"heartbeat",
"messages",
"contains",
"all",
"the",
"servers",
"in",
"the",
"hub",
"and",
"all",
"the",
"pods",
"known",
"to",
"the",
"hub",
"server",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/bartender/heartbeat/HeartbeatImpl.java#L1008-L1034 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/bartender/heartbeat/HeartbeatImpl.java | HeartbeatImpl.sendSpokeHeartbeats | private void sendSpokeHeartbeats()
{
for (ServerTarget target : _targets) {
ServerHeartbeat server = target.getServer();
if (server.getRack() != _rack) {
continue;
}
if (isHub(server)) {
target.sendServerHeartbeat(getServerSelf().getUpdate());
}
}
} | java | private void sendSpokeHeartbeats()
{
for (ServerTarget target : _targets) {
ServerHeartbeat server = target.getServer();
if (server.getRack() != _rack) {
continue;
}
if (isHub(server)) {
target.sendServerHeartbeat(getServerSelf().getUpdate());
}
}
} | [
"private",
"void",
"sendSpokeHeartbeats",
"(",
")",
"{",
"for",
"(",
"ServerTarget",
"target",
":",
"_targets",
")",
"{",
"ServerHeartbeat",
"server",
"=",
"target",
".",
"getServer",
"(",
")",
";",
"if",
"(",
"server",
".",
"getRack",
"(",
")",
"!=",
"_... | Sends a server status message to the hub servers. The server message
contains the status for the current server. | [
"Sends",
"a",
"server",
"status",
"message",
"to",
"the",
"hub",
"servers",
".",
"The",
"server",
"message",
"contains",
"the",
"status",
"for",
"the",
"current",
"server",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/bartender/heartbeat/HeartbeatImpl.java#L1040-L1053 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/profile/HeapDump.java | HeapDump.isAvailable | public static boolean isAvailable()
{
try {
return create() != null;
} catch (Exception e) {
log.log(Level.FINEST, e.toString(), e);
return false;
}
} | java | public static boolean isAvailable()
{
try {
return create() != null;
} catch (Exception e) {
log.log(Level.FINEST, e.toString(), e);
return false;
}
} | [
"public",
"static",
"boolean",
"isAvailable",
"(",
")",
"{",
"try",
"{",
"return",
"create",
"(",
")",
"!=",
"null",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",
"{",
"log",
".",
"log",
"(",
"Level",
".",
"FINEST",
",",
"e",
".",
"toString",
"(",... | Checks if the heap is available | [
"Checks",
"if",
"the",
"heap",
"is",
"available"
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/profile/HeapDump.java#L77-L86 | train |
Dissem/Jabit | core/src/main/java/ch/dissem/bitmessage/factory/V3MessageReader.java | V3MessageReader.cleanup | public void cleanup() {
state = null;
if (headerBuffer != null) {
bufferPool.deallocate(headerBuffer);
}
if (dataBuffer != null) {
bufferPool.deallocate(dataBuffer);
}
} | java | public void cleanup() {
state = null;
if (headerBuffer != null) {
bufferPool.deallocate(headerBuffer);
}
if (dataBuffer != null) {
bufferPool.deallocate(dataBuffer);
}
} | [
"public",
"void",
"cleanup",
"(",
")",
"{",
"state",
"=",
"null",
";",
"if",
"(",
"headerBuffer",
"!=",
"null",
")",
"{",
"bufferPool",
".",
"deallocate",
"(",
"headerBuffer",
")",
";",
"}",
"if",
"(",
"dataBuffer",
"!=",
"null",
")",
"{",
"bufferPool"... | De-allocates all buffers. This method should be called iff the reader isn't used anymore, i.e. when its
connection is severed. | [
"De",
"-",
"allocates",
"all",
"buffers",
".",
"This",
"method",
"should",
"be",
"called",
"iff",
"the",
"reader",
"isn",
"t",
"used",
"anymore",
"i",
".",
"e",
".",
"when",
"its",
"connection",
"is",
"severed",
"."
] | 64ee41aee81c537aa27818e93e6afcd2ca1b7844 | https://github.com/Dissem/Jabit/blob/64ee41aee81c537aa27818e93e6afcd2ca1b7844/core/src/main/java/ch/dissem/bitmessage/factory/V3MessageReader.java#L178-L186 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/bartender/heartbeat/ServerTarget.java | ServerTarget.clusterHeartbeat | void clusterHeartbeat(String clusterId,
UpdateServerHeartbeat updateSelf,
UpdateRackHeartbeat updateRack,
UpdatePodSystem updatePod,
long sequence)
{
if (startUpdate(updateRack, updatePod)) {
getHeartbeat().clusterHeartbeat(clusterId, updateSelf, updateRack, updatePod, sequence);
}
} | java | void clusterHeartbeat(String clusterId,
UpdateServerHeartbeat updateSelf,
UpdateRackHeartbeat updateRack,
UpdatePodSystem updatePod,
long sequence)
{
if (startUpdate(updateRack, updatePod)) {
getHeartbeat().clusterHeartbeat(clusterId, updateSelf, updateRack, updatePod, sequence);
}
} | [
"void",
"clusterHeartbeat",
"(",
"String",
"clusterId",
",",
"UpdateServerHeartbeat",
"updateSelf",
",",
"UpdateRackHeartbeat",
"updateRack",
",",
"UpdatePodSystem",
"updatePod",
",",
"long",
"sequence",
")",
"{",
"if",
"(",
"startUpdate",
"(",
"updateRack",
",",
"u... | Sends a cluster heartbeat message if the update has changed, or it's time
for a periodic heartbeat.
The cluster heartbeat message include all information for a foreign cluster. | [
"Sends",
"a",
"cluster",
"heartbeat",
"message",
"if",
"the",
"update",
"has",
"changed",
"or",
"it",
"s",
"time",
"for",
"a",
"periodic",
"heartbeat",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/bartender/heartbeat/ServerTarget.java#L87-L96 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/bartender/heartbeat/ServerTarget.java | ServerTarget.hubHeartbeat | void hubHeartbeat(UpdateServerHeartbeat updateServer,
UpdateRackHeartbeat updateRack,
UpdatePodSystem updatePod,
long sequence)
{
if (startUpdate(updateRack, updatePod)) {
getHeartbeat().hubHeartbeat(updateServer, updateRack, updatePod, sequence);
}
} | java | void hubHeartbeat(UpdateServerHeartbeat updateServer,
UpdateRackHeartbeat updateRack,
UpdatePodSystem updatePod,
long sequence)
{
if (startUpdate(updateRack, updatePod)) {
getHeartbeat().hubHeartbeat(updateServer, updateRack, updatePod, sequence);
}
} | [
"void",
"hubHeartbeat",
"(",
"UpdateServerHeartbeat",
"updateServer",
",",
"UpdateRackHeartbeat",
"updateRack",
",",
"UpdatePodSystem",
"updatePod",
",",
"long",
"sequence",
")",
"{",
"if",
"(",
"startUpdate",
"(",
"updateRack",
",",
"updatePod",
")",
")",
"{",
"g... | Sends a hub heartbeat message if the update has changed, or it's time
for a periodic heartbeat.
The hub heartbeat message include all information for the current cluster
from a hub server. | [
"Sends",
"a",
"hub",
"heartbeat",
"message",
"if",
"the",
"update",
"has",
"changed",
"or",
"it",
"s",
"time",
"for",
"a",
"periodic",
"heartbeat",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/bartender/heartbeat/ServerTarget.java#L105-L113 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/bartender/heartbeat/ServerTarget.java | ServerTarget.startUpdate | private boolean startUpdate(UpdateRackHeartbeat updateRack,
UpdatePodSystem updatePod)
{
long now = CurrentTime.currentTime();
if (_lastHubTime + getTimeout() < now) {
}
else if (_lastRackCrc != updateRack.getCrc()) {
}
else if (updatePod != null && _lastPodCrc != updatePod.getCrc()) {
}
else {
return false;
}
_lastHubTime = now;
_lastRackCrc = updateRack.getCrc();
if (updatePod != null) {
_lastPodCrc = updatePod.getCrc();
}
return true;
} | java | private boolean startUpdate(UpdateRackHeartbeat updateRack,
UpdatePodSystem updatePod)
{
long now = CurrentTime.currentTime();
if (_lastHubTime + getTimeout() < now) {
}
else if (_lastRackCrc != updateRack.getCrc()) {
}
else if (updatePod != null && _lastPodCrc != updatePod.getCrc()) {
}
else {
return false;
}
_lastHubTime = now;
_lastRackCrc = updateRack.getCrc();
if (updatePod != null) {
_lastPodCrc = updatePod.getCrc();
}
return true;
} | [
"private",
"boolean",
"startUpdate",
"(",
"UpdateRackHeartbeat",
"updateRack",
",",
"UpdatePodSystem",
"updatePod",
")",
"{",
"long",
"now",
"=",
"CurrentTime",
".",
"currentTime",
"(",
")",
";",
"if",
"(",
"_lastHubTime",
"+",
"getTimeout",
"(",
")",
"<",
"no... | Only send updates on changes or timeouts. | [
"Only",
"send",
"updates",
"on",
"changes",
"or",
"timeouts",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/bartender/heartbeat/ServerTarget.java#L118-L141 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/bartender/pod/NodePodProxy.java | NodePodProxy.owner | @Override
public int owner(int hash)
{
NodePodAmp delegate = delegate();
if (delegate != null) {
return delegate().owner(hash);
}
else {
return 0;
}
} | java | @Override
public int owner(int hash)
{
NodePodAmp delegate = delegate();
if (delegate != null) {
return delegate().owner(hash);
}
else {
return 0;
}
} | [
"@",
"Override",
"public",
"int",
"owner",
"(",
"int",
"hash",
")",
"{",
"NodePodAmp",
"delegate",
"=",
"delegate",
"(",
")",
";",
"if",
"(",
"delegate",
"!=",
"null",
")",
"{",
"return",
"delegate",
"(",
")",
".",
"owner",
"(",
"hash",
")",
";",
"... | The owner index for the node. | [
"The",
"owner",
"index",
"for",
"the",
"node",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/bartender/pod/NodePodProxy.java#L121-L132 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/bartender/hamp/LinkHamp.java | LinkHamp.run | @Override
public void run()
{
try {
while (! isClosed() && _is.read() > 0 && _in.readMessage(_is)) {
ServiceRef.flushOutbox();
}
} catch (EOFException e) {
log.finer(this + " end of file");
if (log.isLoggable(Level.ALL)) {
log.log(Level.ALL, e.toString(), e);
}
} catch (SocketException e) {
e.printStackTrace();
log.finer(this + " socket closed:" + e);
if (log.isLoggable(Level.ALL)) {
log.log(Level.ALL, e.toString(), e);
}
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
} catch (Throwable e) {
e.printStackTrace();
throw e;
} finally {
close();
}
} | java | @Override
public void run()
{
try {
while (! isClosed() && _is.read() > 0 && _in.readMessage(_is)) {
ServiceRef.flushOutbox();
}
} catch (EOFException e) {
log.finer(this + " end of file");
if (log.isLoggable(Level.ALL)) {
log.log(Level.ALL, e.toString(), e);
}
} catch (SocketException e) {
e.printStackTrace();
log.finer(this + " socket closed:" + e);
if (log.isLoggable(Level.ALL)) {
log.log(Level.ALL, e.toString(), e);
}
} catch (IOException e) {
e.printStackTrace();
throw new RuntimeException(e);
} catch (Throwable e) {
e.printStackTrace();
throw e;
} finally {
close();
}
} | [
"@",
"Override",
"public",
"void",
"run",
"(",
")",
"{",
"try",
"{",
"while",
"(",
"!",
"isClosed",
"(",
")",
"&&",
"_is",
".",
"read",
"(",
")",
">",
"0",
"&&",
"_in",
".",
"readMessage",
"(",
"_is",
")",
")",
"{",
"ServiceRef",
".",
"flushOutbo... | Receive messages from the client | [
"Receive",
"messages",
"from",
"the",
"client"
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/bartender/hamp/LinkHamp.java#L196-L225 | train |
baratine/baratine | web/src/main/java/com/caucho/v5/http/protocol/RequestHttp1.java | RequestHttp1.getHost | @Override
protected CharSequence getHost()
{
if (_host != null)
return _host;
if (_uriHost.length() > 0) {
_host = _uriHost;
}
else if ((_host = getForwardedHostHeader()) != null) {
}
else {
_host = getHostHeader();
}
return _host;
} | java | @Override
protected CharSequence getHost()
{
if (_host != null)
return _host;
if (_uriHost.length() > 0) {
_host = _uriHost;
}
else if ((_host = getForwardedHostHeader()) != null) {
}
else {
_host = getHostHeader();
}
return _host;
} | [
"@",
"Override",
"protected",
"CharSequence",
"getHost",
"(",
")",
"{",
"if",
"(",
"_host",
"!=",
"null",
")",
"return",
"_host",
";",
"if",
"(",
"_uriHost",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"_host",
"=",
"_uriHost",
";",
"}",
"else",
"... | Returns the virtual host of the request | [
"Returns",
"the",
"virtual",
"host",
"of",
"the",
"request"
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/http/protocol/RequestHttp1.java#L277-L293 | train |
baratine/baratine | web/src/main/java/com/caucho/v5/http/protocol/RequestHttp1.java | RequestHttp1.hostInvocation | private CharSequence hostInvocation()
throws IOException
{
if (_host != null) {
}
else if (_uriHost.length() > 0) {
_host = _uriHost;
}
else if ((_host = getForwardedHostHeader()) != null) {
}
else if ((_host = getHostHeader()) != null) {
}
else if (HTTP_1_1 <= version()) {
throw new BadRequestException(L.l("HTTP/1.1 requires a Host header (Remote IP={0})",
connTcp().ipRemote()));
}
return _host;
} | java | private CharSequence hostInvocation()
throws IOException
{
if (_host != null) {
}
else if (_uriHost.length() > 0) {
_host = _uriHost;
}
else if ((_host = getForwardedHostHeader()) != null) {
}
else if ((_host = getHostHeader()) != null) {
}
else if (HTTP_1_1 <= version()) {
throw new BadRequestException(L.l("HTTP/1.1 requires a Host header (Remote IP={0})",
connTcp().ipRemote()));
}
return _host;
} | [
"private",
"CharSequence",
"hostInvocation",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"_host",
"!=",
"null",
")",
"{",
"}",
"else",
"if",
"(",
"_uriHost",
".",
"length",
"(",
")",
">",
"0",
")",
"{",
"_host",
"=",
"_uriHost",
";",
"}",
"els... | Returns the virtual host from the invocation | [
"Returns",
"the",
"virtual",
"host",
"from",
"the",
"invocation"
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/http/protocol/RequestHttp1.java#L298-L316 | train |
baratine/baratine | web/src/main/java/com/caucho/v5/http/protocol/RequestHttp1.java | RequestHttp1.header | @Override
public String header(String key)
{
CharSegment buf = getHeaderBuffer(key);
if (buf != null)
return buf.toString();
else
return null;
} | java | @Override
public String header(String key)
{
CharSegment buf = getHeaderBuffer(key);
if (buf != null)
return buf.toString();
else
return null;
} | [
"@",
"Override",
"public",
"String",
"header",
"(",
"String",
"key",
")",
"{",
"CharSegment",
"buf",
"=",
"getHeaderBuffer",
"(",
"key",
")",
";",
"if",
"(",
"buf",
"!=",
"null",
")",
"return",
"buf",
".",
"toString",
"(",
")",
";",
"else",
"return",
... | Returns the header. | [
"Returns",
"the",
"header",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/http/protocol/RequestHttp1.java#L426-L435 | train |
baratine/baratine | web/src/main/java/com/caucho/v5/http/protocol/RequestHttp1.java | RequestHttp1.getHeaderBuffer | public CharSegment getHeaderBuffer(char []testBuf, int length)
{
char []keyBuf = _headerBuffer;
CharSegment []headerKeys = _headerKeys;
char []toLowerAscii = _toLowerAscii;
for (int i = _headerSize - 1; i >= 0; i--) {
CharSegment key = headerKeys[i];
if (key.length() != length)
continue;
int offset = key.offset();
int j;
for (j = length - 1; j >= 0; j--) {
char a = testBuf[j];
char b = keyBuf[offset + j];
if (a == b) {
continue;
}
else if (toLowerAscii[a] != toLowerAscii[b]) {
break;
}
}
if (j < 0) {
return _headerValues[i];
}
}
return null;
} | java | public CharSegment getHeaderBuffer(char []testBuf, int length)
{
char []keyBuf = _headerBuffer;
CharSegment []headerKeys = _headerKeys;
char []toLowerAscii = _toLowerAscii;
for (int i = _headerSize - 1; i >= 0; i--) {
CharSegment key = headerKeys[i];
if (key.length() != length)
continue;
int offset = key.offset();
int j;
for (j = length - 1; j >= 0; j--) {
char a = testBuf[j];
char b = keyBuf[offset + j];
if (a == b) {
continue;
}
else if (toLowerAscii[a] != toLowerAscii[b]) {
break;
}
}
if (j < 0) {
return _headerValues[i];
}
}
return null;
} | [
"public",
"CharSegment",
"getHeaderBuffer",
"(",
"char",
"[",
"]",
"testBuf",
",",
"int",
"length",
")",
"{",
"char",
"[",
"]",
"keyBuf",
"=",
"_headerBuffer",
";",
"CharSegment",
"[",
"]",
"headerKeys",
"=",
"_headerKeys",
";",
"char",
"[",
"]",
"toLowerA... | Returns the matching header.
@param testBuf header key
@param length length of the key. | [
"Returns",
"the",
"matching",
"header",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/http/protocol/RequestHttp1.java#L470-L504 | train |
baratine/baratine | web/src/main/java/com/caucho/v5/http/protocol/RequestHttp1.java | RequestHttp1.getHeaderBuffer | @Override
public CharSegment getHeaderBuffer(String key)
{
int i = matchNextHeader(0, key);
if (i >= 0) {
return _headerValues[i];
}
else {
return null;
}
} | java | @Override
public CharSegment getHeaderBuffer(String key)
{
int i = matchNextHeader(0, key);
if (i >= 0) {
return _headerValues[i];
}
else {
return null;
}
} | [
"@",
"Override",
"public",
"CharSegment",
"getHeaderBuffer",
"(",
"String",
"key",
")",
"{",
"int",
"i",
"=",
"matchNextHeader",
"(",
"0",
",",
"key",
")",
";",
"if",
"(",
"i",
">=",
"0",
")",
"{",
"return",
"_headerValues",
"[",
"i",
"]",
";",
"}",
... | Returns the header value for the key, returned as a CharSegment. | [
"Returns",
"the",
"header",
"value",
"for",
"the",
"key",
"returned",
"as",
"a",
"CharSegment",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/http/protocol/RequestHttp1.java#L509-L520 | train |
baratine/baratine | web/src/main/java/com/caucho/v5/http/protocol/RequestHttp1.java | RequestHttp1.getHeaderBuffers | @Override
public void getHeaderBuffers(String key, ArrayList<CharSegment> values)
{
int i = -1;
while ((i = matchNextHeader(i + 1, key)) >= 0) {
values.add(_headerValues[i]);
}
} | java | @Override
public void getHeaderBuffers(String key, ArrayList<CharSegment> values)
{
int i = -1;
while ((i = matchNextHeader(i + 1, key)) >= 0) {
values.add(_headerValues[i]);
}
} | [
"@",
"Override",
"public",
"void",
"getHeaderBuffers",
"(",
"String",
"key",
",",
"ArrayList",
"<",
"CharSegment",
">",
"values",
")",
"{",
"int",
"i",
"=",
"-",
"1",
";",
"while",
"(",
"(",
"i",
"=",
"matchNextHeader",
"(",
"i",
"+",
"1",
",",
"key"... | Fills an ArrayList with the header values matching the key.
@param values ArrayList which will contain the maching values.
@param key the header key to select. | [
"Fills",
"an",
"ArrayList",
"with",
"the",
"header",
"values",
"matching",
"the",
"key",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/http/protocol/RequestHttp1.java#L528-L536 | train |
baratine/baratine | web/src/main/java/com/caucho/v5/http/protocol/RequestHttp1.java | RequestHttp1.getHeaders | @Override
public Enumeration<String> getHeaders(String key)
{
ArrayList<String> values = new ArrayList<String>();
int i = -1;
while ((i = matchNextHeader(i + 1, key)) >= 0) {
values.add(_headerValues[i].toString());
}
return Collections.enumeration(values);
} | java | @Override
public Enumeration<String> getHeaders(String key)
{
ArrayList<String> values = new ArrayList<String>();
int i = -1;
while ((i = matchNextHeader(i + 1, key)) >= 0) {
values.add(_headerValues[i].toString());
}
return Collections.enumeration(values);
} | [
"@",
"Override",
"public",
"Enumeration",
"<",
"String",
">",
"getHeaders",
"(",
"String",
"key",
")",
"{",
"ArrayList",
"<",
"String",
">",
"values",
"=",
"new",
"ArrayList",
"<",
"String",
">",
"(",
")",
";",
"int",
"i",
"=",
"-",
"1",
";",
"while"... | Return an enumeration of headers matching a key.
@param key the header key to match.
@return the enumeration of the headers. | [
"Return",
"an",
"enumeration",
"of",
"headers",
"matching",
"a",
"key",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/http/protocol/RequestHttp1.java#L544-L555 | train |
baratine/baratine | web/src/main/java/com/caucho/v5/http/protocol/RequestHttp1.java | RequestHttp1.matchNextHeader | private int matchNextHeader(int i, String key)
{
int size = _headerSize;
int length = key.length();
char []keyBuf = _headerBuffer;
char []toLowerAscii = _toLowerAscii;
for (; i < size; i++) {
CharSegment header = _headerKeys[i];
if (header.length() != length)
continue;
int offset = header.offset();
int j;
for (j = 0; j < length; j++) {
char a = key.charAt(j);
char b = keyBuf[offset + j];
if (a == b) {
continue;
}
else if (toLowerAscii[a] != toLowerAscii[b]) {
break;
}
}
if (j == length) {
return i;
}
}
return -1;
} | java | private int matchNextHeader(int i, String key)
{
int size = _headerSize;
int length = key.length();
char []keyBuf = _headerBuffer;
char []toLowerAscii = _toLowerAscii;
for (; i < size; i++) {
CharSegment header = _headerKeys[i];
if (header.length() != length)
continue;
int offset = header.offset();
int j;
for (j = 0; j < length; j++) {
char a = key.charAt(j);
char b = keyBuf[offset + j];
if (a == b) {
continue;
}
else if (toLowerAscii[a] != toLowerAscii[b]) {
break;
}
}
if (j == length) {
return i;
}
}
return -1;
} | [
"private",
"int",
"matchNextHeader",
"(",
"int",
"i",
",",
"String",
"key",
")",
"{",
"int",
"size",
"=",
"_headerSize",
";",
"int",
"length",
"=",
"key",
".",
"length",
"(",
")",
";",
"char",
"[",
"]",
"keyBuf",
"=",
"_headerBuffer",
";",
"char",
"[... | Returns the index of the next header matching the key.
@param i header index to start search
@param key header key to match
@return the index of the next header matching, or -1. | [
"Returns",
"the",
"index",
"of",
"the",
"next",
"header",
"matching",
"the",
"key",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/http/protocol/RequestHttp1.java#L565-L600 | train |
baratine/baratine | web/src/main/java/com/caucho/v5/http/protocol/RequestHttp1.java | RequestHttp1.setHeader | @Override
public void setHeader(String key, String value)
{
int tail;
if (_headerSize > 0) {
tail = (_headerValues[_headerSize - 1].offset()
+ _headerValues[_headerSize - 1].length());
}
else {
tail = 0;
}
int keyLength = key.length();
int valueLength = value.length();
char []headerBuffer = _headerBuffer;
for (int i = keyLength - 1; i >= 0; i--) {
headerBuffer[tail + i] = key.charAt(i);
}
_headerKeys[_headerSize].init(headerBuffer, tail, keyLength);
tail += keyLength;
for (int i = valueLength - 1; i >= 0; i--) {
headerBuffer[tail + i] = value.charAt(i);
}
_headerValues[_headerSize].init(headerBuffer, tail, valueLength);
_headerSize++;
// XXX: size
} | java | @Override
public void setHeader(String key, String value)
{
int tail;
if (_headerSize > 0) {
tail = (_headerValues[_headerSize - 1].offset()
+ _headerValues[_headerSize - 1].length());
}
else {
tail = 0;
}
int keyLength = key.length();
int valueLength = value.length();
char []headerBuffer = _headerBuffer;
for (int i = keyLength - 1; i >= 0; i--) {
headerBuffer[tail + i] = key.charAt(i);
}
_headerKeys[_headerSize].init(headerBuffer, tail, keyLength);
tail += keyLength;
for (int i = valueLength - 1; i >= 0; i--) {
headerBuffer[tail + i] = value.charAt(i);
}
_headerValues[_headerSize].init(headerBuffer, tail, valueLength);
_headerSize++;
// XXX: size
} | [
"@",
"Override",
"public",
"void",
"setHeader",
"(",
"String",
"key",
",",
"String",
"value",
")",
"{",
"int",
"tail",
";",
"if",
"(",
"_headerSize",
">",
"0",
")",
"{",
"tail",
"=",
"(",
"_headerValues",
"[",
"_headerSize",
"-",
"1",
"]",
".",
"offs... | Adds a new header. Used only by the caching to simulate
If-Modified-Since.
@param key the key of the new header
@param value the value for the new header | [
"Adds",
"a",
"new",
"header",
".",
"Used",
"only",
"by",
"the",
"caching",
"to",
"simulate",
"If",
"-",
"Modified",
"-",
"Since",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/http/protocol/RequestHttp1.java#L609-L641 | train |
baratine/baratine | web/src/main/java/com/caucho/v5/http/protocol/RequestHttp1.java | RequestHttp1.parseRequest | private boolean parseRequest()
throws IOException
{
try {
ReadStream is = connTcp().readStream();
if (! readRequest(is)) {
clearRequest();
return false;
}
_sequence = connHttp().nextSequenceRead();
if (log.isLoggable(Level.FINE)) {
log.fine(_method + " "
+ new String(_uri, 0, _uriLength) + " " + _protocol
+ " (" + dbgId() + ")");
log.fine("Remote-IP: " + connTcp().addressRemote()
+ ":" + connTcp().portRemote() + " (" + dbgId() + ")");
}
parseHeaders(is);
return true;
} catch (ClientDisconnectException e) {
throw e;
} catch (SocketTimeoutException e) {
log.log(Level.FINER, e.toString(), e);
return false;
} catch (ArrayIndexOutOfBoundsException e) {
log.log(Level.FINEST, e.toString(), e);
throw new BadRequestException(L.l("Invalid request: URL or headers are too long"), e);
} catch (Throwable e) {
log.log(Level.FINEST, e.toString(), e);
throw new BadRequestException(String.valueOf(e), e);
}
} | java | private boolean parseRequest()
throws IOException
{
try {
ReadStream is = connTcp().readStream();
if (! readRequest(is)) {
clearRequest();
return false;
}
_sequence = connHttp().nextSequenceRead();
if (log.isLoggable(Level.FINE)) {
log.fine(_method + " "
+ new String(_uri, 0, _uriLength) + " " + _protocol
+ " (" + dbgId() + ")");
log.fine("Remote-IP: " + connTcp().addressRemote()
+ ":" + connTcp().portRemote() + " (" + dbgId() + ")");
}
parseHeaders(is);
return true;
} catch (ClientDisconnectException e) {
throw e;
} catch (SocketTimeoutException e) {
log.log(Level.FINER, e.toString(), e);
return false;
} catch (ArrayIndexOutOfBoundsException e) {
log.log(Level.FINEST, e.toString(), e);
throw new BadRequestException(L.l("Invalid request: URL or headers are too long"), e);
} catch (Throwable e) {
log.log(Level.FINEST, e.toString(), e);
throw new BadRequestException(String.valueOf(e), e);
}
} | [
"private",
"boolean",
"parseRequest",
"(",
")",
"throws",
"IOException",
"{",
"try",
"{",
"ReadStream",
"is",
"=",
"connTcp",
"(",
")",
".",
"readStream",
"(",
")",
";",
"if",
"(",
"!",
"readRequest",
"(",
"is",
")",
")",
"{",
"clearRequest",
"(",
")",... | Parses a http request. | [
"Parses",
"a",
"http",
"request",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/http/protocol/RequestHttp1.java#L681-L721 | train |
baratine/baratine | web/src/main/java/com/caucho/v5/http/protocol/RequestHttp1.java | RequestHttp1.initRequest | @Override
protected void initRequest()
{
super.initRequest();
_state = _state.toActive();
// HttpBufferStore httpBuffer = getHttpBufferStore();
HttpBufferStore bufferStore = getHttpBufferStore();
_method.clear();
_methodString = null;
_protocol.clear();
_uriLength = 0;
if (bufferStore == null) {
// server/05h8
_uri = getSmallUriBuffer(); // httpBuffer.getUriBuffer();
_headerBuffer = getSmallHeaderBuffer(); // httpBuffer.getHeaderBuffer();
_headerKeys = getSmallHeaderKeys(); // httpBuffer.getHeaderKeys();
_headerValues = getSmallHeaderValues(); // httpBuffer.getHeaderValues();
}
_uriHost.clear();
_host = null;
_keepalive = KeepaliveState.INIT;
_headerSize = 0;
_headerLength = 0;
_inOffset = 0;
_isChunkedIn = false;
_isFirst = true;
} | java | @Override
protected void initRequest()
{
super.initRequest();
_state = _state.toActive();
// HttpBufferStore httpBuffer = getHttpBufferStore();
HttpBufferStore bufferStore = getHttpBufferStore();
_method.clear();
_methodString = null;
_protocol.clear();
_uriLength = 0;
if (bufferStore == null) {
// server/05h8
_uri = getSmallUriBuffer(); // httpBuffer.getUriBuffer();
_headerBuffer = getSmallHeaderBuffer(); // httpBuffer.getHeaderBuffer();
_headerKeys = getSmallHeaderKeys(); // httpBuffer.getHeaderKeys();
_headerValues = getSmallHeaderValues(); // httpBuffer.getHeaderValues();
}
_uriHost.clear();
_host = null;
_keepalive = KeepaliveState.INIT;
_headerSize = 0;
_headerLength = 0;
_inOffset = 0;
_isChunkedIn = false;
_isFirst = true;
} | [
"@",
"Override",
"protected",
"void",
"initRequest",
"(",
")",
"{",
"super",
".",
"initRequest",
"(",
")",
";",
"_state",
"=",
"_state",
".",
"toActive",
"(",
")",
";",
"// HttpBufferStore httpBuffer = getHttpBufferStore();",
"HttpBufferStore",
"bufferStore",
"=",
... | Clear the request variables in preparation for a new request.
@param s the read stream for the request | [
"Clear",
"the",
"request",
"variables",
"in",
"preparation",
"for",
"a",
"new",
"request",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/http/protocol/RequestHttp1.java#L735-L769 | train |
baratine/baratine | web/src/main/java/com/caucho/v5/http/protocol/RequestHttp1.java | RequestHttp1.onTimeout | @Override
public void onTimeout()
{
try {
//request().sendError(WebRequest.INTERNAL_SERVER_ERROR);
if (true) throw new UnsupportedOperationException();
} catch (Exception e) {
log.log(Level.FINEST, e.toString(), e);
}
closeResponse();
} | java | @Override
public void onTimeout()
{
try {
//request().sendError(WebRequest.INTERNAL_SERVER_ERROR);
if (true) throw new UnsupportedOperationException();
} catch (Exception e) {
log.log(Level.FINEST, e.toString(), e);
}
closeResponse();
} | [
"@",
"Override",
"public",
"void",
"onTimeout",
"(",
")",
"{",
"try",
"{",
"//request().sendError(WebRequest.INTERNAL_SERVER_ERROR);",
"if",
"(",
"true",
")",
"throw",
"new",
"UnsupportedOperationException",
"(",
")",
";",
"}",
"catch",
"(",
"Exception",
"e",
")",... | Handles a timeout. | [
"Handles",
"a",
"timeout",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/http/protocol/RequestHttp1.java#L1662-L1673 | train |
SeaCloudsEU/SeaCloudsPlatform | sla/sla-core/sla-service/src/main/java/eu/atos/sla/service/rest/PenaltyRestEntity.java | PenaltyRestEntity.getPenaltyByUuid | @GET
@Path("{uuid}")
public Penalty getPenaltyByUuid(@PathParam("uuid") UUID uuid) {
logger.debug("StartOf getPenaltyByUuid - REQUEST for /penalties/{}", uuid);
PenaltyHelperE penaltyRestHelper = getPenaltyHelper();
Penalty result = penaltyRestHelper.getPenaltyByUuid(uuid);
logger.debug("EndOf getPenaltyByUuid");
return result;
} | java | @GET
@Path("{uuid}")
public Penalty getPenaltyByUuid(@PathParam("uuid") UUID uuid) {
logger.debug("StartOf getPenaltyByUuid - REQUEST for /penalties/{}", uuid);
PenaltyHelperE penaltyRestHelper = getPenaltyHelper();
Penalty result = penaltyRestHelper.getPenaltyByUuid(uuid);
logger.debug("EndOf getPenaltyByUuid");
return result;
} | [
"@",
"GET",
"@",
"Path",
"(",
"\"{uuid}\"",
")",
"public",
"Penalty",
"getPenaltyByUuid",
"(",
"@",
"PathParam",
"(",
"\"uuid\"",
")",
"UUID",
"uuid",
")",
"{",
"logger",
".",
"debug",
"(",
"\"StartOf getPenaltyByUuid - REQUEST for /penalties/{}\"",
",",
"uuid",
... | Returns the information of an specific penalty given an uuid.
@return violations according to parameters in the query string. | [
"Returns",
"the",
"information",
"of",
"an",
"specific",
"penalty",
"given",
"an",
"uuid",
"."
] | b199fe6de2c63b808cb248d3aca947d802375df8 | https://github.com/SeaCloudsEU/SeaCloudsPlatform/blob/b199fe6de2c63b808cb248d3aca947d802375df8/sla/sla-core/sla-service/src/main/java/eu/atos/sla/service/rest/PenaltyRestEntity.java#L68-L76 | train |
SeaCloudsEU/SeaCloudsPlatform | sla/sla-core/sla-service/src/main/java/eu/atos/sla/service/rest/PenaltyRestEntity.java | PenaltyRestEntity.getPenalties | @GET
public List<Penalty> getPenalties(
@QueryParam("agreementId") String agreementId,
@QueryParam("guaranteeTerm") String guaranteeTerm,
@QueryParam("begin") DateParam begin, @QueryParam("end") DateParam end) throws InternalException{
logger.debug("StartOf getPenalties REQUEST for /penalties/?agreementId={}&guaranteeTerm={}&begin={}&end={}",
agreementId, guaranteeTerm, begin, end);
Date dBegin = (begin == null)? null : begin.getDate();
Date dEnd = (end == null)? null : end.getDate();
PenaltyHelperE penaltyRestHelper = getPenaltyHelper();
List<Penalty> penalties;
try{
penalties = penaltyRestHelper.getPenalties(agreementId, guaranteeTerm, dBegin, dEnd);
} catch (ParserHelperException e) {
throw new InternalException(e.getMessage());
}
logger.debug("EndOf getPenalties");
return penalties;
} | java | @GET
public List<Penalty> getPenalties(
@QueryParam("agreementId") String agreementId,
@QueryParam("guaranteeTerm") String guaranteeTerm,
@QueryParam("begin") DateParam begin, @QueryParam("end") DateParam end) throws InternalException{
logger.debug("StartOf getPenalties REQUEST for /penalties/?agreementId={}&guaranteeTerm={}&begin={}&end={}",
agreementId, guaranteeTerm, begin, end);
Date dBegin = (begin == null)? null : begin.getDate();
Date dEnd = (end == null)? null : end.getDate();
PenaltyHelperE penaltyRestHelper = getPenaltyHelper();
List<Penalty> penalties;
try{
penalties = penaltyRestHelper.getPenalties(agreementId, guaranteeTerm, dBegin, dEnd);
} catch (ParserHelperException e) {
throw new InternalException(e.getMessage());
}
logger.debug("EndOf getPenalties");
return penalties;
} | [
"@",
"GET",
"public",
"List",
"<",
"Penalty",
">",
"getPenalties",
"(",
"@",
"QueryParam",
"(",
"\"agreementId\"",
")",
"String",
"agreementId",
",",
"@",
"QueryParam",
"(",
"\"guaranteeTerm\"",
")",
"String",
"guaranteeTerm",
",",
"@",
"QueryParam",
"(",
"\"b... | Search penalties given several query terms.
If no parameters specified, return all penalties.
@param agreementId
@param guaranteeTerm
@param begin
@param end
@return penalties according to parameters in the query string. | [
"Search",
"penalties",
"given",
"several",
"query",
"terms",
"."
] | b199fe6de2c63b808cb248d3aca947d802375df8 | https://github.com/SeaCloudsEU/SeaCloudsPlatform/blob/b199fe6de2c63b808cb248d3aca947d802375df8/sla/sla-core/sla-service/src/main/java/eu/atos/sla/service/rest/PenaltyRestEntity.java#L89-L109 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/bartender/network/ServerNetwork.java | ServerNetwork.getLoadBalanceSocketPool | public final ClientSocketFactory getLoadBalanceSocketPool()
{
ClientSocketFactory factory = getLoadBalanceSocketFactory();
if (factory == null)
return null;
if (_serverBartender.getState().isDisableSoft()) {
factory.enableSessionOnly();
}
else if (_serverBartender.getState().isDisabled()){
// server/269g
factory.disable();
}
else {
factory.enable();
}
return factory;
} | java | public final ClientSocketFactory getLoadBalanceSocketPool()
{
ClientSocketFactory factory = getLoadBalanceSocketFactory();
if (factory == null)
return null;
if (_serverBartender.getState().isDisableSoft()) {
factory.enableSessionOnly();
}
else if (_serverBartender.getState().isDisabled()){
// server/269g
factory.disable();
}
else {
factory.enable();
}
return factory;
} | [
"public",
"final",
"ClientSocketFactory",
"getLoadBalanceSocketPool",
"(",
")",
"{",
"ClientSocketFactory",
"factory",
"=",
"getLoadBalanceSocketFactory",
"(",
")",
";",
"if",
"(",
"factory",
"==",
"null",
")",
"return",
"null",
";",
"if",
"(",
"_serverBartender",
... | Returns the socket pool as a load-balancer. | [
"Returns",
"the",
"socket",
"pool",
"as",
"a",
"load",
"-",
"balancer",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/bartender/network/ServerNetwork.java#L903-L922 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/bartender/network/ServerNetwork.java | ServerNetwork.onHeartbeatStop | boolean onHeartbeatStop()
{
SocketPool clusterSocketPool;
if (isExternal()) {
clusterSocketPool = _clusterSocketPool.getAndSet(null);
}
else {
clusterSocketPool = _clusterSocketPool.get();
}
if (clusterSocketPool != null) {
clusterSocketPool.getFactory().notifyHeartbeatStop();
}
/*
if (! _heartbeatState.notifyHeartbeatStop()) {
return false;
}
*/
log.fine("notify-heartbeat-stop " + this);
return true;
} | java | boolean onHeartbeatStop()
{
SocketPool clusterSocketPool;
if (isExternal()) {
clusterSocketPool = _clusterSocketPool.getAndSet(null);
}
else {
clusterSocketPool = _clusterSocketPool.get();
}
if (clusterSocketPool != null) {
clusterSocketPool.getFactory().notifyHeartbeatStop();
}
/*
if (! _heartbeatState.notifyHeartbeatStop()) {
return false;
}
*/
log.fine("notify-heartbeat-stop " + this);
return true;
} | [
"boolean",
"onHeartbeatStop",
"(",
")",
"{",
"SocketPool",
"clusterSocketPool",
";",
"if",
"(",
"isExternal",
"(",
")",
")",
"{",
"clusterSocketPool",
"=",
"_clusterSocketPool",
".",
"getAndSet",
"(",
"null",
")",
";",
"}",
"else",
"{",
"clusterSocketPool",
"=... | Notify that a stop event has been received. | [
"Notify",
"that",
"a",
"stop",
"event",
"has",
"been",
"received",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/bartender/network/ServerNetwork.java#L1197-L1221 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/bartender/network/ServerNetwork.java | ServerNetwork.close | public void close()
{
SocketPool loadBalancePool = _loadBalanceSocketPool.get();
if (loadBalancePool != null)
loadBalancePool.getFactory().close();
SocketPool clusterPool = _clusterSocketPool.get();
if (clusterPool != null)
clusterPool.getFactory().close();
} | java | public void close()
{
SocketPool loadBalancePool = _loadBalanceSocketPool.get();
if (loadBalancePool != null)
loadBalancePool.getFactory().close();
SocketPool clusterPool = _clusterSocketPool.get();
if (clusterPool != null)
clusterPool.getFactory().close();
} | [
"public",
"void",
"close",
"(",
")",
"{",
"SocketPool",
"loadBalancePool",
"=",
"_loadBalanceSocketPool",
".",
"get",
"(",
")",
";",
"if",
"(",
"loadBalancePool",
"!=",
"null",
")",
"loadBalancePool",
".",
"getFactory",
"(",
")",
".",
"close",
"(",
")",
";... | Close any ports. | [
"Close",
"any",
"ports",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/bartender/network/ServerNetwork.java#L1279-L1290 | train |
baratine/baratine | kraken/src/main/java/com/caucho/v5/h3/io/OutFactoryH3Impl.java | OutFactoryH3Impl.schema | @Override
public void schema(Class<?> type)
{
Objects.requireNonNull(type);
_context.schema(type);
} | java | @Override
public void schema(Class<?> type)
{
Objects.requireNonNull(type);
_context.schema(type);
} | [
"@",
"Override",
"public",
"void",
"schema",
"(",
"Class",
"<",
"?",
">",
"type",
")",
"{",
"Objects",
".",
"requireNonNull",
"(",
"type",
")",
";",
"_context",
".",
"schema",
"(",
"type",
")",
";",
"}"
] | Adds a predefined schema | [
"Adds",
"a",
"predefined",
"schema"
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/h3/io/OutFactoryH3Impl.java#L64-L70 | train |
baratine/baratine | core/src/main/java/com/caucho/v5/util/RandomUtil.java | RandomUtil.getRandomLong | public static long getRandomLong()
{
Random random = getRandom();
long value = random.nextLong();
if (! _isTest) {
_freeRandomList.free(random);
}
return value;
} | java | public static long getRandomLong()
{
Random random = getRandom();
long value = random.nextLong();
if (! _isTest) {
_freeRandomList.free(random);
}
return value;
} | [
"public",
"static",
"long",
"getRandomLong",
"(",
")",
"{",
"Random",
"random",
"=",
"getRandom",
"(",
")",
";",
"long",
"value",
"=",
"random",
".",
"nextLong",
"(",
")",
";",
"if",
"(",
"!",
"_isTest",
")",
"{",
"_freeRandomList",
".",
"free",
"(",
... | Returns the next random long. | [
"Returns",
"the",
"next",
"random",
"long",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/util/RandomUtil.java#L49-L60 | train |
baratine/baratine | core/src/main/java/com/caucho/v5/util/RandomUtil.java | RandomUtil.nextInt | public static int nextInt(int n)
{
Random random = getRandom();
int value = random.nextInt(n);
if (! _isTest)
_freeRandomList.free(random);
return value;
} | java | public static int nextInt(int n)
{
Random random = getRandom();
int value = random.nextInt(n);
if (! _isTest)
_freeRandomList.free(random);
return value;
} | [
"public",
"static",
"int",
"nextInt",
"(",
"int",
"n",
")",
"{",
"Random",
"random",
"=",
"getRandom",
"(",
")",
";",
"int",
"value",
"=",
"random",
".",
"nextInt",
"(",
"n",
")",
";",
"if",
"(",
"!",
"_isTest",
")",
"_freeRandomList",
".",
"free",
... | Returns the next random int. | [
"Returns",
"the",
"next",
"random",
"int",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/util/RandomUtil.java#L65-L75 | train |
baratine/baratine | core/src/main/java/com/caucho/v5/util/RandomUtil.java | RandomUtil.nextDouble | public static double nextDouble()
{
Random random = getRandom();
double value = random.nextDouble();
if (! _isTest)
_freeRandomList.free(random);
return value;
} | java | public static double nextDouble()
{
Random random = getRandom();
double value = random.nextDouble();
if (! _isTest)
_freeRandomList.free(random);
return value;
} | [
"public",
"static",
"double",
"nextDouble",
"(",
")",
"{",
"Random",
"random",
"=",
"getRandom",
"(",
")",
";",
"double",
"value",
"=",
"random",
".",
"nextDouble",
"(",
")",
";",
"if",
"(",
"!",
"_isTest",
")",
"_freeRandomList",
".",
"free",
"(",
"ra... | Returns the next random double between 0 and 1 | [
"Returns",
"the",
"next",
"random",
"double",
"between",
"0",
"and",
"1"
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/util/RandomUtil.java#L80-L90 | train |
baratine/baratine | core/src/main/java/com/caucho/v5/util/RandomUtil.java | RandomUtil.getRandom | public static Random getRandom()
{
if (_isTest) {
return _testRandom;
}
Random random = _freeRandomList.allocate();
if (random == null) {
random = new SecureRandom();
}
return random;
} | java | public static Random getRandom()
{
if (_isTest) {
return _testRandom;
}
Random random = _freeRandomList.allocate();
if (random == null) {
random = new SecureRandom();
}
return random;
} | [
"public",
"static",
"Random",
"getRandom",
"(",
")",
"{",
"if",
"(",
"_isTest",
")",
"{",
"return",
"_testRandom",
";",
"}",
"Random",
"random",
"=",
"_freeRandomList",
".",
"allocate",
"(",
")",
";",
"if",
"(",
"random",
"==",
"null",
")",
"{",
"rando... | Returns the random generator. | [
"Returns",
"the",
"random",
"generator",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/util/RandomUtil.java#L95-L108 | train |
baratine/baratine | kraken/src/main/java/com/caucho/v5/h3/io/OutRawH3Impl.java | OutRawH3Impl.writeChunk | @Override
public void writeChunk(long length, boolean isFinal)
{
long chunk;
if (isFinal) {
chunk = length << 1;
}
else {
chunk = (length << 1) + 1;
}
writeUnsigned(chunk);
} | java | @Override
public void writeChunk(long length, boolean isFinal)
{
long chunk;
if (isFinal) {
chunk = length << 1;
}
else {
chunk = (length << 1) + 1;
}
writeUnsigned(chunk);
} | [
"@",
"Override",
"public",
"void",
"writeChunk",
"(",
"long",
"length",
",",
"boolean",
"isFinal",
")",
"{",
"long",
"chunk",
";",
"if",
"(",
"isFinal",
")",
"{",
"chunk",
"=",
"length",
"<<",
"1",
";",
"}",
"else",
"{",
"chunk",
"=",
"(",
"length",
... | chunked header. LSB | [
"chunked",
"header",
".",
"LSB"
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/h3/io/OutRawH3Impl.java#L201-L214 | train |
baratine/baratine | kraken/src/main/java/com/caucho/v5/h3/io/OutRawH3Impl.java | OutRawH3Impl.writeStringData | @Override
public void writeStringData(String value, int offset, int length)
{
char []cBuf = _charBuffer;
int cBufLength = cBuf.length;
for (int i = 0; i < length; i += cBufLength) {
int sublen = Math.min(length - i, cBufLength);
value.getChars(offset + i, offset + i + sublen, cBuf, 0);
writeStringChunk(cBuf, 0, sublen);
}
} | java | @Override
public void writeStringData(String value, int offset, int length)
{
char []cBuf = _charBuffer;
int cBufLength = cBuf.length;
for (int i = 0; i < length; i += cBufLength) {
int sublen = Math.min(length - i, cBufLength);
value.getChars(offset + i, offset + i + sublen, cBuf, 0);
writeStringChunk(cBuf, 0, sublen);
}
} | [
"@",
"Override",
"public",
"void",
"writeStringData",
"(",
"String",
"value",
",",
"int",
"offset",
",",
"int",
"length",
")",
"{",
"char",
"[",
"]",
"cBuf",
"=",
"_charBuffer",
";",
"int",
"cBufLength",
"=",
"cBuf",
".",
"length",
";",
"for",
"(",
"in... | string data without length | [
"string",
"data",
"without",
"length"
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/h3/io/OutRawH3Impl.java#L219-L232 | train |
baratine/baratine | kraken/src/main/java/com/caucho/v5/h3/io/OutRawH3Impl.java | OutRawH3Impl.writeBinaryData | @Override
public void writeBinaryData(byte []sBuf, int sOffset, int sLength)
{
byte []tBuf = _buffer;
int tOffset = _offset;
int tLength = tBuf.length;
int end = sOffset + sLength;
while (sOffset < end) {
if (tLength - tOffset < 1) {
tOffset = flush(tOffset);
}
int sublen = Math.min(tLength - tOffset, end - sOffset);
System.arraycopy(sBuf, sOffset, tBuf, tOffset, sublen);
tOffset += sublen;
sOffset += sublen;
}
_offset = tOffset;
} | java | @Override
public void writeBinaryData(byte []sBuf, int sOffset, int sLength)
{
byte []tBuf = _buffer;
int tOffset = _offset;
int tLength = tBuf.length;
int end = sOffset + sLength;
while (sOffset < end) {
if (tLength - tOffset < 1) {
tOffset = flush(tOffset);
}
int sublen = Math.min(tLength - tOffset, end - sOffset);
System.arraycopy(sBuf, sOffset, tBuf, tOffset, sublen);
tOffset += sublen;
sOffset += sublen;
}
_offset = tOffset;
} | [
"@",
"Override",
"public",
"void",
"writeBinaryData",
"(",
"byte",
"[",
"]",
"sBuf",
",",
"int",
"sOffset",
",",
"int",
"sLength",
")",
"{",
"byte",
"[",
"]",
"tBuf",
"=",
"_buffer",
";",
"int",
"tOffset",
"=",
"_offset",
";",
"int",
"tLength",
"=",
... | binary data without type or length | [
"binary",
"data",
"without",
"type",
"or",
"length"
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/h3/io/OutRawH3Impl.java#L275-L298 | train |
baratine/baratine | kraken/src/main/java/com/caucho/v5/h3/io/OutRawH3Impl.java | OutRawH3Impl.require | private void require(int len)
{
int offset = _offset;
int length = _length;
if (offset + len < length) {
return;
}
flush(_offset);
} | java | private void require(int len)
{
int offset = _offset;
int length = _length;
if (offset + len < length) {
return;
}
flush(_offset);
} | [
"private",
"void",
"require",
"(",
"int",
"len",
")",
"{",
"int",
"offset",
"=",
"_offset",
";",
"int",
"length",
"=",
"_length",
";",
"if",
"(",
"offset",
"+",
"len",
"<",
"length",
")",
"{",
"return",
";",
"}",
"flush",
"(",
"_offset",
")",
";",
... | Require empty space in the output buffer.
If not enough space is available, flush the buffer. | [
"Require",
"empty",
"space",
"in",
"the",
"output",
"buffer",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/h3/io/OutRawH3Impl.java#L305-L315 | train |
baratine/baratine | kraken/src/main/java/com/caucho/v5/h3/io/OutRawH3Impl.java | OutRawH3Impl.flush | private int flush(int offset)
{
try {
_os.write(_buffer, 0, offset);
_offset = 0;
return 0;
} catch (IOException e) {
throw new H3ExceptionOut(e);
}
} | java | private int flush(int offset)
{
try {
_os.write(_buffer, 0, offset);
_offset = 0;
return 0;
} catch (IOException e) {
throw new H3ExceptionOut(e);
}
} | [
"private",
"int",
"flush",
"(",
"int",
"offset",
")",
"{",
"try",
"{",
"_os",
".",
"write",
"(",
"_buffer",
",",
"0",
",",
"offset",
")",
";",
"_offset",
"=",
"0",
";",
"return",
"0",
";",
"}",
"catch",
"(",
"IOException",
"e",
")",
"{",
"throw",... | Flush the buffer and set the offset to zero. | [
"Flush",
"the",
"buffer",
"and",
"set",
"the",
"offset",
"to",
"zero",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/h3/io/OutRawH3Impl.java#L320-L330 | train |
baratine/baratine | kraken/src/main/java/com/caucho/v5/h3/io/OutRawH3Impl.java | OutRawH3Impl.writeRef | @Override
public void writeRef(int ref)
{
require(1);
_buffer[_offset++] = (byte) ConstH3.REF;
writeUnsigned(ref);
} | java | @Override
public void writeRef(int ref)
{
require(1);
_buffer[_offset++] = (byte) ConstH3.REF;
writeUnsigned(ref);
} | [
"@",
"Override",
"public",
"void",
"writeRef",
"(",
"int",
"ref",
")",
"{",
"require",
"(",
"1",
")",
";",
"_buffer",
"[",
"_offset",
"++",
"]",
"=",
"(",
"byte",
")",
"ConstH3",
".",
"REF",
";",
"writeUnsigned",
"(",
"ref",
")",
";",
"}"
] | write graph reference | [
"write",
"graph",
"reference"
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/h3/io/OutRawH3Impl.java#L392-L399 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/vfs/PathImpl.java | PathImpl.lookup | public final PathImpl lookup(URL url)
{
String name = URLDecoder.decode(url.toString());
return lookup(name, null);
} | java | public final PathImpl lookup(URL url)
{
String name = URLDecoder.decode(url.toString());
return lookup(name, null);
} | [
"public",
"final",
"PathImpl",
"lookup",
"(",
"URL",
"url",
")",
"{",
"String",
"name",
"=",
"URLDecoder",
".",
"decode",
"(",
"url",
".",
"toString",
"(",
")",
")",
";",
"return",
"lookup",
"(",
"name",
",",
"null",
")",
";",
"}"
] | Looks up a path by a URL. | [
"Looks",
"up",
"a",
"path",
"by",
"a",
"URL",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/PathImpl.java#L166-L171 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/vfs/PathImpl.java | PathImpl.lookupRelativeNativePath | public String lookupRelativeNativePath(PathImpl path)
{
String thisNative = getNativePath();
String pathNative = path.getNativePath();
if (pathNative.startsWith(thisNative)) {
int i = thisNative.length();
while (i < pathNative.length()) {
if (pathNative.charAt(i) != getFileSeparatorChar())
break;
i++;
}
return i == pathNative.length() ? "" : pathNative.substring(i);
}
else
return pathNative;
} | java | public String lookupRelativeNativePath(PathImpl path)
{
String thisNative = getNativePath();
String pathNative = path.getNativePath();
if (pathNative.startsWith(thisNative)) {
int i = thisNative.length();
while (i < pathNative.length()) {
if (pathNative.charAt(i) != getFileSeparatorChar())
break;
i++;
}
return i == pathNative.length() ? "" : pathNative.substring(i);
}
else
return pathNative;
} | [
"public",
"String",
"lookupRelativeNativePath",
"(",
"PathImpl",
"path",
")",
"{",
"String",
"thisNative",
"=",
"getNativePath",
"(",
")",
";",
"String",
"pathNative",
"=",
"path",
".",
"getNativePath",
"(",
")",
";",
"if",
"(",
"pathNative",
".",
"startsWith"... | Returns a native path relative to this native path if the passed path
is relative to this path, or an absolute path if the passed path is not
relative to this path. | [
"Returns",
"a",
"native",
"path",
"relative",
"to",
"this",
"native",
"path",
"if",
"the",
"passed",
"path",
"is",
"relative",
"to",
"this",
"path",
"or",
"an",
"absolute",
"path",
"if",
"the",
"passed",
"path",
"is",
"not",
"relative",
"to",
"this",
"pa... | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/PathImpl.java#L344-L363 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/vfs/PathImpl.java | PathImpl.getResources | public ArrayList<PathImpl> getResources(String name)
{
ArrayList<PathImpl> list = new ArrayList<PathImpl>();
PathImpl path = lookup(name);
if (path.exists())
list.add(path);
return list;
} | java | public ArrayList<PathImpl> getResources(String name)
{
ArrayList<PathImpl> list = new ArrayList<PathImpl>();
PathImpl path = lookup(name);
if (path.exists())
list.add(path);
return list;
} | [
"public",
"ArrayList",
"<",
"PathImpl",
">",
"getResources",
"(",
"String",
"name",
")",
"{",
"ArrayList",
"<",
"PathImpl",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"PathImpl",
">",
"(",
")",
";",
"PathImpl",
"path",
"=",
"lookup",
"(",
"name",
")",
... | Looks up all the resources matching a name. (Generally only useful
with MergePath. | [
"Looks",
"up",
"all",
"the",
"resources",
"matching",
"a",
"name",
".",
"(",
"Generally",
"only",
"useful",
"with",
"MergePath",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/PathImpl.java#L369-L377 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/vfs/PathImpl.java | PathImpl.getResources | public ArrayList<PathImpl> getResources()
{
ArrayList<PathImpl> list = new ArrayList<PathImpl>();
//if (exists())
list.add(this);
return list;
} | java | public ArrayList<PathImpl> getResources()
{
ArrayList<PathImpl> list = new ArrayList<PathImpl>();
//if (exists())
list.add(this);
return list;
} | [
"public",
"ArrayList",
"<",
"PathImpl",
">",
"getResources",
"(",
")",
"{",
"ArrayList",
"<",
"PathImpl",
">",
"list",
"=",
"new",
"ArrayList",
"<",
"PathImpl",
">",
"(",
")",
";",
"//if (exists())",
"list",
".",
"add",
"(",
"this",
")",
";",
"return",
... | Looks up all the existing resources. (Generally only useful
with MergePath. | [
"Looks",
"up",
"all",
"the",
"existing",
"resources",
".",
"(",
"Generally",
"only",
"useful",
"with",
"MergePath",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/PathImpl.java#L383-L391 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/vfs/PathImpl.java | PathImpl.scanScheme | protected String scanScheme(String uri)
{
int i = 0;
if (uri == null)
return null;
int length = uri.length();
if (length == 0)
return null;
int ch = uri.charAt(0);
if (ch >= 'a' && ch <= 'z' ||
ch >= 'A' && ch <= 'Z') {
for (i = 1; i < length; i++) {
ch = uri.charAt(i);
if (ch == ':')
return uri.substring(0, i).toLowerCase(Locale.ENGLISH);
if (! (ch >= 'a' && ch <= 'z' ||
ch >= 'A' && ch <= 'Z' ||
ch >= '0' && ch <= '0' ||
ch == '+' || ch == '-' || ch == '.'))
break;
}
}
return null;
} | java | protected String scanScheme(String uri)
{
int i = 0;
if (uri == null)
return null;
int length = uri.length();
if (length == 0)
return null;
int ch = uri.charAt(0);
if (ch >= 'a' && ch <= 'z' ||
ch >= 'A' && ch <= 'Z') {
for (i = 1; i < length; i++) {
ch = uri.charAt(i);
if (ch == ':')
return uri.substring(0, i).toLowerCase(Locale.ENGLISH);
if (! (ch >= 'a' && ch <= 'z' ||
ch >= 'A' && ch <= 'Z' ||
ch >= '0' && ch <= '0' ||
ch == '+' || ch == '-' || ch == '.'))
break;
}
}
return null;
} | [
"protected",
"String",
"scanScheme",
"(",
"String",
"uri",
")",
"{",
"int",
"i",
"=",
"0",
";",
"if",
"(",
"uri",
"==",
"null",
")",
"return",
"null",
";",
"int",
"length",
"=",
"uri",
".",
"length",
"(",
")",
";",
"if",
"(",
"length",
"==",
"0",... | Returns the scheme portion of a uri. Since schemes are case-insensitive,
normalize them to lower case. | [
"Returns",
"the",
"scheme",
"portion",
"of",
"a",
"uri",
".",
"Since",
"schemes",
"are",
"case",
"-",
"insensitive",
"normalize",
"them",
"to",
"lower",
"case",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/PathImpl.java#L405-L433 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/vfs/PathImpl.java | PathImpl.isWindowsInsecure | public boolean isWindowsInsecure()
{
String lower = getPath().toLowerCase(Locale.ENGLISH);
int lastCh;
if ((lastCh = lower.charAt(lower.length() - 1)) == '.'
|| lastCh == ' ' || lastCh == '*' || lastCh == '?'
|| ((lastCh == '/' || lastCh == '\\') && ! isDirectory())
|| lower.endsWith("::$data")
|| isWindowsSpecial(lower, "/con")
|| isWindowsSpecial(lower, "/aux")
|| isWindowsSpecial(lower, "/prn")
|| isWindowsSpecial(lower, "/nul")
|| isWindowsSpecial(lower, "/com1")
|| isWindowsSpecial(lower, "/com2")
|| isWindowsSpecial(lower, "/com3")
|| isWindowsSpecial(lower, "/com4")
|| isWindowsSpecial(lower, "/lpt1")
|| isWindowsSpecial(lower, "/lpt2")
|| isWindowsSpecial(lower, "/lpt3")) {
return true;
}
return false;
} | java | public boolean isWindowsInsecure()
{
String lower = getPath().toLowerCase(Locale.ENGLISH);
int lastCh;
if ((lastCh = lower.charAt(lower.length() - 1)) == '.'
|| lastCh == ' ' || lastCh == '*' || lastCh == '?'
|| ((lastCh == '/' || lastCh == '\\') && ! isDirectory())
|| lower.endsWith("::$data")
|| isWindowsSpecial(lower, "/con")
|| isWindowsSpecial(lower, "/aux")
|| isWindowsSpecial(lower, "/prn")
|| isWindowsSpecial(lower, "/nul")
|| isWindowsSpecial(lower, "/com1")
|| isWindowsSpecial(lower, "/com2")
|| isWindowsSpecial(lower, "/com3")
|| isWindowsSpecial(lower, "/com4")
|| isWindowsSpecial(lower, "/lpt1")
|| isWindowsSpecial(lower, "/lpt2")
|| isWindowsSpecial(lower, "/lpt3")) {
return true;
}
return false;
} | [
"public",
"boolean",
"isWindowsInsecure",
"(",
")",
"{",
"String",
"lower",
"=",
"getPath",
"(",
")",
".",
"toLowerCase",
"(",
"Locale",
".",
"ENGLISH",
")",
";",
"int",
"lastCh",
";",
"if",
"(",
"(",
"lastCh",
"=",
"lower",
".",
"charAt",
"(",
"lower"... | Returns true for windows security issues. | [
"Returns",
"true",
"for",
"windows",
"security",
"issues",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/PathImpl.java#L579-L604 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/vfs/PathImpl.java | PathImpl.iterator | public Iterator<String> iterator() throws IOException
{
String list[] = list();
// Avoids NPE when subclasses override list() and
// possibly return null, e.g. JarPath.
if (list == null)
list = new String[0];
return new ArrayIterator(list);
} | java | public Iterator<String> iterator() throws IOException
{
String list[] = list();
// Avoids NPE when subclasses override list() and
// possibly return null, e.g. JarPath.
if (list == null)
list = new String[0];
return new ArrayIterator(list);
} | [
"public",
"Iterator",
"<",
"String",
">",
"iterator",
"(",
")",
"throws",
"IOException",
"{",
"String",
"list",
"[",
"]",
"=",
"list",
"(",
")",
";",
"// Avoids NPE when subclasses override list() and",
"// possibly return null, e.g. JarPath.",
"if",
"(",
"list",
"=... | Returns a jdk1.2 Iterator for the contents of this directory. | [
"Returns",
"a",
"jdk1",
".",
"2",
"Iterator",
"for",
"the",
"contents",
"of",
"this",
"directory",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/PathImpl.java#L982-L992 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/vfs/PathImpl.java | PathImpl.removeAll | public boolean removeAll() throws IOException
{
if (isDirectory() && ! isLink()) {
String []list = list();
for (int i = 0; i < list.length; i++) {
PathImpl subpath = lookup(list[i]);
subpath.removeAll();
}
}
return remove();
} | java | public boolean removeAll() throws IOException
{
if (isDirectory() && ! isLink()) {
String []list = list();
for (int i = 0; i < list.length; i++) {
PathImpl subpath = lookup(list[i]);
subpath.removeAll();
}
}
return remove();
} | [
"public",
"boolean",
"removeAll",
"(",
")",
"throws",
"IOException",
"{",
"if",
"(",
"isDirectory",
"(",
")",
"&&",
"!",
"isLink",
"(",
")",
")",
"{",
"String",
"[",
"]",
"list",
"=",
"list",
"(",
")",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
... | Removes the all files and directories below this path.
@return true if successful. | [
"Removes",
"the",
"all",
"files",
"and",
"directories",
"below",
"this",
"path",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/PathImpl.java#L1027-L1039 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/vfs/PathImpl.java | PathImpl.createNewFile | public boolean createNewFile() throws IOException
{
synchronized (LOCK) {
if (! exists()) {
clearStatusCache();
WriteStreamOld s = openWrite();
s.close();
return true;
}
}
return false;
} | java | public boolean createNewFile() throws IOException
{
synchronized (LOCK) {
if (! exists()) {
clearStatusCache();
WriteStreamOld s = openWrite();
s.close();
return true;
}
}
return false;
} | [
"public",
"boolean",
"createNewFile",
"(",
")",
"throws",
"IOException",
"{",
"synchronized",
"(",
"LOCK",
")",
"{",
"if",
"(",
"!",
"exists",
"(",
")",
")",
"{",
"clearStatusCache",
"(",
")",
";",
"WriteStreamOld",
"s",
"=",
"openWrite",
"(",
")",
";",
... | Creates the file named by this Path and returns true if the
file is new. | [
"Creates",
"the",
"file",
"named",
"by",
"this",
"Path",
"and",
"returns",
"true",
"if",
"the",
"file",
"is",
"new",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/PathImpl.java#L1309-L1321 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/vfs/PathImpl.java | PathImpl.getCrc64 | public long getCrc64()
{
try {
if (isDirectory()) {
String []list = list();
long digest = 0x1;
for (int i = 0; i < list.length; i++) {
digest = Crc64.generate(digest, list[i]);
}
return digest;
}
else if (canRead()) {
ReadStreamOld is = openRead();
try {
long digest = 0x1;
byte []buffer = is.buffer();
while (is.fillBuffer() > 0) {
int length = is.getLength();
digest = Crc64.generate(digest, buffer, 0, length);
}
return digest;
} finally {
is.close();
}
}
else {
return 0; // Depend requires -1
}
} catch (IOException e) {
// XXX: log
e.printStackTrace();
return -1;
}
} | java | public long getCrc64()
{
try {
if (isDirectory()) {
String []list = list();
long digest = 0x1;
for (int i = 0; i < list.length; i++) {
digest = Crc64.generate(digest, list[i]);
}
return digest;
}
else if (canRead()) {
ReadStreamOld is = openRead();
try {
long digest = 0x1;
byte []buffer = is.buffer();
while (is.fillBuffer() > 0) {
int length = is.getLength();
digest = Crc64.generate(digest, buffer, 0, length);
}
return digest;
} finally {
is.close();
}
}
else {
return 0; // Depend requires -1
}
} catch (IOException e) {
// XXX: log
e.printStackTrace();
return -1;
}
} | [
"public",
"long",
"getCrc64",
"(",
")",
"{",
"try",
"{",
"if",
"(",
"isDirectory",
"(",
")",
")",
"{",
"String",
"[",
"]",
"list",
"=",
"list",
"(",
")",
";",
"long",
"digest",
"=",
"0x1",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",... | Returns the crc64 code. | [
"Returns",
"the",
"crc64",
"code",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/PathImpl.java#L1483-L1524 | train |
baratine/baratine | kraken/src/main/java/com/caucho/v5/kelp/JournalKelpImpl.java | JournalKelpImpl.put | void put(RowCursor cursor)
{
boolean isValid;
do {
isValid = true;
try (JournalOutputStream os = openItem()) {
os.write(CODE_PUT);
cursor.writeJournal(os);
isValid = os.complete();
} catch (IOException e) {
log.log(Level.FINER, e.toString(), e);
}
} while (! isValid);
} | java | void put(RowCursor cursor)
{
boolean isValid;
do {
isValid = true;
try (JournalOutputStream os = openItem()) {
os.write(CODE_PUT);
cursor.writeJournal(os);
isValid = os.complete();
} catch (IOException e) {
log.log(Level.FINER, e.toString(), e);
}
} while (! isValid);
} | [
"void",
"put",
"(",
"RowCursor",
"cursor",
")",
"{",
"boolean",
"isValid",
";",
"do",
"{",
"isValid",
"=",
"true",
";",
"try",
"(",
"JournalOutputStream",
"os",
"=",
"openItem",
"(",
")",
")",
"{",
"os",
".",
"write",
"(",
"CODE_PUT",
")",
";",
"curs... | Writes the put to the journal. | [
"Writes",
"the",
"put",
"to",
"the",
"journal",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/JournalKelpImpl.java#L103-L120 | train |
baratine/baratine | kraken/src/main/java/com/caucho/v5/kelp/JournalKelpImpl.java | JournalKelpImpl.remove | void remove(RowCursor cursor)
{
boolean isValid;
do {
isValid = true;
try (JournalOutputStream os = openItem()) {
os.write(CODE_REMOVE);
cursor.getKey(_buffer, 0);
os.write(_buffer, 0, getKeyLength());
try {
BitsUtil.writeLong(os, cursor.getVersion());
} catch (IOException e) {
throw new RuntimeException(e);
}
isValid = os.complete();
}
} while (! isValid);
} | java | void remove(RowCursor cursor)
{
boolean isValid;
do {
isValid = true;
try (JournalOutputStream os = openItem()) {
os.write(CODE_REMOVE);
cursor.getKey(_buffer, 0);
os.write(_buffer, 0, getKeyLength());
try {
BitsUtil.writeLong(os, cursor.getVersion());
} catch (IOException e) {
throw new RuntimeException(e);
}
isValid = os.complete();
}
} while (! isValid);
} | [
"void",
"remove",
"(",
"RowCursor",
"cursor",
")",
"{",
"boolean",
"isValid",
";",
"do",
"{",
"isValid",
"=",
"true",
";",
"try",
"(",
"JournalOutputStream",
"os",
"=",
"openItem",
"(",
")",
")",
"{",
"os",
".",
"write",
"(",
"CODE_REMOVE",
")",
";",
... | Writes the remove to the journal. | [
"Writes",
"the",
"remove",
"to",
"the",
"journal",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/JournalKelpImpl.java#L125-L147 | train |
SeaCloudsEU/SeaCloudsPlatform | sla/sla-core/sla-service/src/main/java/eu/atos/sla/service/rest/Tower4CloudsTranslator.java | Tower4CloudsTranslator.initTermsMap | private MultivaluedMapWrapper<String, IGuaranteeTerm> initTermsMap(IAgreement agreement) {
MultivaluedMapWrapper<String, IGuaranteeTerm> result = new MultivaluedMapWrapper<String, IGuaranteeTerm>();
for (IGuaranteeTerm term : agreement.getGuaranteeTerms()) {
String variable = constraintEvaluator.getConstraintVariable(term.getServiceLevel());
result.add(variable, term);
}
return result;
} | java | private MultivaluedMapWrapper<String, IGuaranteeTerm> initTermsMap(IAgreement agreement) {
MultivaluedMapWrapper<String, IGuaranteeTerm> result = new MultivaluedMapWrapper<String, IGuaranteeTerm>();
for (IGuaranteeTerm term : agreement.getGuaranteeTerms()) {
String variable = constraintEvaluator.getConstraintVariable(term.getServiceLevel());
result.add(variable, term);
}
return result;
} | [
"private",
"MultivaluedMapWrapper",
"<",
"String",
",",
"IGuaranteeTerm",
">",
"initTermsMap",
"(",
"IAgreement",
"agreement",
")",
"{",
"MultivaluedMapWrapper",
"<",
"String",
",",
"IGuaranteeTerm",
">",
"result",
"=",
"new",
"MultivaluedMapWrapper",
"<",
"String",
... | Inits a MultivaluedMap with metrickey as key and the terms that evaluate the metrickey as values.
@param agreement
@return | [
"Inits",
"a",
"MultivaluedMap",
"with",
"metrickey",
"as",
"key",
"and",
"the",
"terms",
"that",
"evaluate",
"the",
"metrickey",
"as",
"values",
"."
] | b199fe6de2c63b808cb248d3aca947d802375df8 | https://github.com/SeaCloudsEU/SeaCloudsPlatform/blob/b199fe6de2c63b808cb248d3aca947d802375df8/sla/sla-core/sla-service/src/main/java/eu/atos/sla/service/rest/Tower4CloudsTranslator.java#L103-L111 | train |
baratine/baratine | web/src/main/java/com/caucho/v5/jni/JniServerSocketImpl.java | JniServerSocketImpl.accept | @Override
public boolean accept(SocketBar socket)
throws IOException
{
JniSocketImpl jniSocket = (JniSocketImpl) socket;
if (_fd == 0)
throw new IOException("accept from closed socket");
return jniSocket.accept(this, _fd, _socketTimeout);
} | java | @Override
public boolean accept(SocketBar socket)
throws IOException
{
JniSocketImpl jniSocket = (JniSocketImpl) socket;
if (_fd == 0)
throw new IOException("accept from closed socket");
return jniSocket.accept(this, _fd, _socketTimeout);
} | [
"@",
"Override",
"public",
"boolean",
"accept",
"(",
"SocketBar",
"socket",
")",
"throws",
"IOException",
"{",
"JniSocketImpl",
"jniSocket",
"=",
"(",
"JniSocketImpl",
")",
"socket",
";",
"if",
"(",
"_fd",
"==",
"0",
")",
"throw",
"new",
"IOException",
"(",
... | Accepts a new connection from the socket.
@param socket the socket connection structure
@return true if the accept returns a new socket. | [
"Accepts",
"a",
"new",
"connection",
"from",
"the",
"socket",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/web/src/main/java/com/caucho/v5/jni/JniServerSocketImpl.java#L306-L316 | train |
baratine/baratine | core/src/main/java/com/caucho/v5/amp/thread/ThreadPoolBase.java | ThreadPoolBase.setIdleMax | public void setIdleMax(int idleMax)
{
if (idleMax <= _idleMin) {
throw new IllegalArgumentException(L.l("idle-max '{0}' must be greater than idle-min '{1}'.",
idleMax, _idleMin));
}
_launcher.setIdleMax(_idleMax);
} | java | public void setIdleMax(int idleMax)
{
if (idleMax <= _idleMin) {
throw new IllegalArgumentException(L.l("idle-max '{0}' must be greater than idle-min '{1}'.",
idleMax, _idleMin));
}
_launcher.setIdleMax(_idleMax);
} | [
"public",
"void",
"setIdleMax",
"(",
"int",
"idleMax",
")",
"{",
"if",
"(",
"idleMax",
"<=",
"_idleMin",
")",
"{",
"throw",
"new",
"IllegalArgumentException",
"(",
"L",
".",
"l",
"(",
"\"idle-max '{0}' must be greater than idle-min '{1}'.\"",
",",
"idleMax",
",",
... | Returns the thread idle max. | [
"Returns",
"the",
"thread",
"idle",
"max",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/amp/thread/ThreadPoolBase.java#L235-L243 | train |
baratine/baratine | core/src/main/java/com/caucho/v5/amp/thread/ThreadPoolBase.java | ThreadPoolBase.schedule | public boolean schedule(Runnable task)
{
ClassLoader loader = Thread.currentThread().getContextClassLoader();
boolean isPriority = false;
boolean isQueue = true;
boolean isWake = true;
return scheduleImpl(task, loader, MAX_EXPIRE, isPriority, isQueue, isWake);
} | java | public boolean schedule(Runnable task)
{
ClassLoader loader = Thread.currentThread().getContextClassLoader();
boolean isPriority = false;
boolean isQueue = true;
boolean isWake = true;
return scheduleImpl(task, loader, MAX_EXPIRE, isPriority, isQueue, isWake);
} | [
"public",
"boolean",
"schedule",
"(",
"Runnable",
"task",
")",
"{",
"ClassLoader",
"loader",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
";",
"boolean",
"isPriority",
"=",
"false",
";",
"boolean",
"isQueue",
"=",
"t... | Schedules a new task. | [
"Schedules",
"a",
"new",
"task",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/amp/thread/ThreadPoolBase.java#L474-L483 | train |
baratine/baratine | core/src/main/java/com/caucho/v5/amp/thread/ThreadPoolBase.java | ThreadPoolBase.wakeThreads | private void wakeThreads(int count)
{
while (true) {
int taskCount = Math.max(0, _taskCount.get());
int spinIdleCount = _spinIdleCount.get();
long threadWakeHead = _threadWakeHead.get();
long threadWakeTail = _threadWakeTail.get();
long threadCount = spinIdleCount + threadWakeHead - threadWakeTail;
if (taskCount <= threadCount) {
return;
}
if (count <= threadCount) {
return;
}
ThreadAmp thread = _idleThreadRing.poll();
if (thread == null) {
return;
}
if (_threadWakeHead.compareAndSet(threadWakeHead, threadWakeHead + 1)) {
thread.setWakeThread();
LockSupport.unpark(thread);
}
else {
// avoid duplicate wake
_idleThreadRing.offer(thread);
}
}
} | java | private void wakeThreads(int count)
{
while (true) {
int taskCount = Math.max(0, _taskCount.get());
int spinIdleCount = _spinIdleCount.get();
long threadWakeHead = _threadWakeHead.get();
long threadWakeTail = _threadWakeTail.get();
long threadCount = spinIdleCount + threadWakeHead - threadWakeTail;
if (taskCount <= threadCount) {
return;
}
if (count <= threadCount) {
return;
}
ThreadAmp thread = _idleThreadRing.poll();
if (thread == null) {
return;
}
if (_threadWakeHead.compareAndSet(threadWakeHead, threadWakeHead + 1)) {
thread.setWakeThread();
LockSupport.unpark(thread);
}
else {
// avoid duplicate wake
_idleThreadRing.offer(thread);
}
}
} | [
"private",
"void",
"wakeThreads",
"(",
"int",
"count",
")",
"{",
"while",
"(",
"true",
")",
"{",
"int",
"taskCount",
"=",
"Math",
".",
"max",
"(",
"0",
",",
"_taskCount",
".",
"get",
"(",
")",
")",
";",
"int",
"spinIdleCount",
"=",
"_spinIdleCount",
... | wake enough threads to process the tasks | [
"wake",
"enough",
"threads",
"to",
"process",
"the",
"tasks"
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/amp/thread/ThreadPoolBase.java#L828-L862 | train |
baratine/baratine | core/src/main/java/com/caucho/v5/amp/thread/ThreadPoolBase.java | ThreadPoolBase.clearIdleThreads | public void clearIdleThreads()
{
_launcher.resetThrottle();
int idleCount = _idleThreadRing.size();
ThreadAmp thread;
while (idleCount-- > 0 && (thread = _idleThreadRing.poll()) != null) {
thread.close();
}
} | java | public void clearIdleThreads()
{
_launcher.resetThrottle();
int idleCount = _idleThreadRing.size();
ThreadAmp thread;
while (idleCount-- > 0 && (thread = _idleThreadRing.poll()) != null) {
thread.close();
}
} | [
"public",
"void",
"clearIdleThreads",
"(",
")",
"{",
"_launcher",
".",
"resetThrottle",
"(",
")",
";",
"int",
"idleCount",
"=",
"_idleThreadRing",
".",
"size",
"(",
")",
";",
"ThreadAmp",
"thread",
";",
"while",
"(",
"idleCount",
"--",
">",
"0",
"&&",
"(... | interrupts all the idle threads. | [
"interrupts",
"all",
"the",
"idle",
"threads",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/amp/thread/ThreadPoolBase.java#L919-L930 | train |
baratine/baratine | core/src/main/java/com/caucho/v5/amp/inbox/InboxQueue.java | InboxQueue.start | @Override
public void start()
{
if (_lifecycle.isActive()) {
return;
}
synchronized (_lifecycle) {
if (! _lifecycle.toInit()) {
return;
}
init(_stubMain);
}
start(_stubMain);
} | java | @Override
public void start()
{
if (_lifecycle.isActive()) {
return;
}
synchronized (_lifecycle) {
if (! _lifecycle.toInit()) {
return;
}
init(_stubMain);
}
start(_stubMain);
} | [
"@",
"Override",
"public",
"void",
"start",
"(",
")",
"{",
"if",
"(",
"_lifecycle",
".",
"isActive",
"(",
")",
")",
"{",
"return",
";",
"}",
"synchronized",
"(",
"_lifecycle",
")",
"{",
"if",
"(",
"!",
"_lifecycle",
".",
"toInit",
"(",
")",
")",
"{... | Start is called lazily when a service is first used. | [
"Start",
"is",
"called",
"lazily",
"when",
"a",
"service",
"is",
"first",
"used",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/amp/inbox/InboxQueue.java#L194-L210 | train |
baratine/baratine | core/src/main/java/com/caucho/v5/amp/inbox/InboxQueue.java | InboxQueue.init | private void init(StubAmp stub)
{
//BuildMessageAmp buildMessage = new BuildMessageAmp(this);
OnInitMessage onInitMsg = new OnInitMessage(this);
_queue.offer(onInitMsg);
_queue.wake();
} | java | private void init(StubAmp stub)
{
//BuildMessageAmp buildMessage = new BuildMessageAmp(this);
OnInitMessage onInitMsg = new OnInitMessage(this);
_queue.offer(onInitMsg);
_queue.wake();
} | [
"private",
"void",
"init",
"(",
"StubAmp",
"stub",
")",
"{",
"//BuildMessageAmp buildMessage = new BuildMessageAmp(this);",
"OnInitMessage",
"onInitMsg",
"=",
"new",
"OnInitMessage",
"(",
"this",
")",
";",
"_queue",
".",
"offer",
"(",
"onInitMsg",
")",
";",
"_queue"... | Init calls the @OnInit methods. | [
"Init",
"calls",
"the"
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/amp/inbox/InboxQueue.java#L230-L238 | train |
baratine/baratine | core/src/main/java/com/caucho/v5/amp/inbox/InboxQueue.java | InboxQueue.shutdown | @Override
public void shutdown(ShutdownModeAmp mode)
{
if (! _lifecycle.toStopping()) {
return;
}
_lifecycle.toDestroy();
OnShutdownMessage shutdownMessage = new OnShutdownMessage(this, mode, isSingle());
_queue.offer(shutdownMessage);
// _queue.close();
/*
for (Actor<?> actorProcessor : _queueActors) {
actorProcessor.close();
}
*/
_queue.wakeAllAndWait();
shutdownMessage.waitFor(1, TimeUnit.SECONDS);
super.shutdown(mode);
try (OutboxAmp outbox = OutboxAmp.currentOrCreate(manager())) {
Object ctx = outbox.getAndSetContext(this);
try {
outbox.flush();
if (! isSingle()) {
_worker.shutdown(mode);
}
} finally {
outbox.getAndSetContext(ctx);
}
}
// XXX: _worker.shutdown(ShutdownModeAmp.IMMEDIATE);
} | java | @Override
public void shutdown(ShutdownModeAmp mode)
{
if (! _lifecycle.toStopping()) {
return;
}
_lifecycle.toDestroy();
OnShutdownMessage shutdownMessage = new OnShutdownMessage(this, mode, isSingle());
_queue.offer(shutdownMessage);
// _queue.close();
/*
for (Actor<?> actorProcessor : _queueActors) {
actorProcessor.close();
}
*/
_queue.wakeAllAndWait();
shutdownMessage.waitFor(1, TimeUnit.SECONDS);
super.shutdown(mode);
try (OutboxAmp outbox = OutboxAmp.currentOrCreate(manager())) {
Object ctx = outbox.getAndSetContext(this);
try {
outbox.flush();
if (! isSingle()) {
_worker.shutdown(mode);
}
} finally {
outbox.getAndSetContext(ctx);
}
}
// XXX: _worker.shutdown(ShutdownModeAmp.IMMEDIATE);
} | [
"@",
"Override",
"public",
"void",
"shutdown",
"(",
"ShutdownModeAmp",
"mode",
")",
"{",
"if",
"(",
"!",
"_lifecycle",
".",
"toStopping",
"(",
")",
")",
"{",
"return",
";",
"}",
"_lifecycle",
".",
"toDestroy",
"(",
")",
";",
"OnShutdownMessage",
"shutdownM... | Closes the inbox | [
"Closes",
"the",
"inbox"
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/amp/inbox/InboxQueue.java#L509-L550 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/util/QDate.java | QDate.setLocalTime | public void setLocalTime(long time)
{
// If this is a local time zone date, just set the time
if (_timeZone != _gmtTimeZone) {
calculateSplit(time);
}
// If this is a GMT date, convert from local to GMT
else {
calculateSplit(time - _localTimeZone.getRawOffset());
try {
long offset = _localTimeZone.getOffset(GregorianCalendar.AD,
(int) _year,
(int) _month,
(int) _dayOfMonth + 1,
getDayOfWeek(),
(int) _timeOfDay);
calculateSplit(time - offset);
} catch (Exception e) {
log.log(Level.FINE, e.toString(), e);
}
}
} | java | public void setLocalTime(long time)
{
// If this is a local time zone date, just set the time
if (_timeZone != _gmtTimeZone) {
calculateSplit(time);
}
// If this is a GMT date, convert from local to GMT
else {
calculateSplit(time - _localTimeZone.getRawOffset());
try {
long offset = _localTimeZone.getOffset(GregorianCalendar.AD,
(int) _year,
(int) _month,
(int) _dayOfMonth + 1,
getDayOfWeek(),
(int) _timeOfDay);
calculateSplit(time - offset);
} catch (Exception e) {
log.log(Level.FINE, e.toString(), e);
}
}
} | [
"public",
"void",
"setLocalTime",
"(",
"long",
"time",
")",
"{",
"// If this is a local time zone date, just set the time",
"if",
"(",
"_timeZone",
"!=",
"_gmtTimeZone",
")",
"{",
"calculateSplit",
"(",
"time",
")",
";",
"}",
"// If this is a GMT date, convert from local ... | Sets the time in milliseconds since the epoch and calculate
the internal variables. | [
"Sets",
"the",
"time",
"in",
"milliseconds",
"since",
"the",
"epoch",
"and",
"calculate",
"the",
"internal",
"variables",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/util/QDate.java#L284-L307 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/util/QDate.java | QDate.getLocalTime | public long getLocalTime()
{
// If this is a local time zone date, just set the time
if (_timeZone != _gmtTimeZone) {
return _localTimeOfEpoch;
}
// If this is a GMT date, convert from local to GMT
else {
long offset = _localTimeZone.getOffset(GregorianCalendar.AD,
(int) _year,
(int) _month,
(int) _dayOfMonth + 1,
getDayOfWeek(),
(int) _timeOfDay);
return _localTimeOfEpoch + offset;
}
} | java | public long getLocalTime()
{
// If this is a local time zone date, just set the time
if (_timeZone != _gmtTimeZone) {
return _localTimeOfEpoch;
}
// If this is a GMT date, convert from local to GMT
else {
long offset = _localTimeZone.getOffset(GregorianCalendar.AD,
(int) _year,
(int) _month,
(int) _dayOfMonth + 1,
getDayOfWeek(),
(int) _timeOfDay);
return _localTimeOfEpoch + offset;
}
} | [
"public",
"long",
"getLocalTime",
"(",
")",
"{",
"// If this is a local time zone date, just set the time",
"if",
"(",
"_timeZone",
"!=",
"_gmtTimeZone",
")",
"{",
"return",
"_localTimeOfEpoch",
";",
"}",
"// If this is a GMT date, convert from local to GMT",
"else",
"{",
"... | Returns the time in milliseconds since the epoch. | [
"Returns",
"the",
"time",
"in",
"milliseconds",
"since",
"the",
"epoch",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/util/QDate.java#L312-L329 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/util/QDate.java | QDate.setMonth | public void setMonth(int month)
{
if (month < 0 || DAYS_IN_MONTH.length <= month)
return;
_month = month;
if (DAYS_IN_MONTH[month] <= _dayOfMonth)
_dayOfMonth = DAYS_IN_MONTH[month] - 1;
calculateJoin();
calculateSplit(_localTimeOfEpoch);
} | java | public void setMonth(int month)
{
if (month < 0 || DAYS_IN_MONTH.length <= month)
return;
_month = month;
if (DAYS_IN_MONTH[month] <= _dayOfMonth)
_dayOfMonth = DAYS_IN_MONTH[month] - 1;
calculateJoin();
calculateSplit(_localTimeOfEpoch);
} | [
"public",
"void",
"setMonth",
"(",
"int",
"month",
")",
"{",
"if",
"(",
"month",
"<",
"0",
"||",
"DAYS_IN_MONTH",
".",
"length",
"<=",
"month",
")",
"return",
";",
"_month",
"=",
"month",
";",
"if",
"(",
"DAYS_IN_MONTH",
"[",
"month",
"]",
"<=",
"_da... | Sets the month in the year. | [
"Sets",
"the",
"month",
"in",
"the",
"year",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/util/QDate.java#L394-L406 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/util/QDate.java | QDate.getWeek | public int getWeek()
{
int dow4th = (int) ((_dayOfEpoch - _dayOfYear + 3) % 7 + 10) % 7;
int ww1monday = 3 - dow4th;
if (_dayOfYear < ww1monday)
return 53;
int week = (_dayOfYear - ww1monday) / 7 + 1;
if (_dayOfYear >= 360) {
int days = 365 + (_isLeapYear ? 1 : 0);
long nextNewYear = (_dayOfEpoch - _dayOfYear + days);
int dowNext4th = (int) ((nextNewYear + 3) % 7 + 10) % 7;
int nextWw1Monday = 3 - dowNext4th;
if (days <= _dayOfYear - nextWw1Monday)
return 1;
}
return week;
} | java | public int getWeek()
{
int dow4th = (int) ((_dayOfEpoch - _dayOfYear + 3) % 7 + 10) % 7;
int ww1monday = 3 - dow4th;
if (_dayOfYear < ww1monday)
return 53;
int week = (_dayOfYear - ww1monday) / 7 + 1;
if (_dayOfYear >= 360) {
int days = 365 + (_isLeapYear ? 1 : 0);
long nextNewYear = (_dayOfEpoch - _dayOfYear + days);
int dowNext4th = (int) ((nextNewYear + 3) % 7 + 10) % 7;
int nextWw1Monday = 3 - dowNext4th;
if (days <= _dayOfYear - nextWw1Monday)
return 1;
}
return week;
} | [
"public",
"int",
"getWeek",
"(",
")",
"{",
"int",
"dow4th",
"=",
"(",
"int",
")",
"(",
"(",
"_dayOfEpoch",
"-",
"_dayOfYear",
"+",
"3",
")",
"%",
"7",
"+",
"10",
")",
"%",
"7",
";",
"int",
"ww1monday",
"=",
"3",
"-",
"dow4th",
";",
"if",
"(",
... | Returns the week in the year. | [
"Returns",
"the",
"week",
"in",
"the",
"year",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/util/QDate.java#L564-L586 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/util/QDate.java | QDate.get | public long get(int field)
{
switch (field) {
case TIME:
return getLocalTime();
case YEAR:
return getYear();
case MONTH:
return getMonth();
case DAY_OF_MONTH:
return getDayOfMonth();
case DAY:
return getDayOfWeek();
case DAY_OF_WEEK:
return getDayOfWeek();
case HOUR:
return getHour();
case MINUTE:
return getMinute();
case SECOND:
return getSecond();
case MILLISECOND:
return getMillisecond();
case TIME_ZONE:
return getZoneOffset() / 1000;
default:
return Long.MAX_VALUE;
}
} | java | public long get(int field)
{
switch (field) {
case TIME:
return getLocalTime();
case YEAR:
return getYear();
case MONTH:
return getMonth();
case DAY_OF_MONTH:
return getDayOfMonth();
case DAY:
return getDayOfWeek();
case DAY_OF_WEEK:
return getDayOfWeek();
case HOUR:
return getHour();
case MINUTE:
return getMinute();
case SECOND:
return getSecond();
case MILLISECOND:
return getMillisecond();
case TIME_ZONE:
return getZoneOffset() / 1000;
default:
return Long.MAX_VALUE;
}
} | [
"public",
"long",
"get",
"(",
"int",
"field",
")",
"{",
"switch",
"(",
"field",
")",
"{",
"case",
"TIME",
":",
"return",
"getLocalTime",
"(",
")",
";",
"case",
"YEAR",
":",
"return",
"getYear",
"(",
")",
";",
"case",
"MONTH",
":",
"return",
"getMonth... | Gets values based on a field. | [
"Gets",
"values",
"based",
"on",
"a",
"field",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/util/QDate.java#L591-L630 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/util/QDate.java | QDate.set | public long set(int field, long value)
{
switch (field) {
case YEAR:
setYear((int) value);
break;
case MONTH:
setMonth((int) value);
break;
case DAY_OF_MONTH:
setDayOfMonth((int) value);
break;
case HOUR:
setHour((int) value);
break;
case MINUTE:
setMinute((int) value);
break;
case SECOND:
setSecond((int) value);
break;
case MILLISECOND:
setMillisecond(value);
break;
default:
throw new RuntimeException();
}
return _localTimeOfEpoch;
} | java | public long set(int field, long value)
{
switch (field) {
case YEAR:
setYear((int) value);
break;
case MONTH:
setMonth((int) value);
break;
case DAY_OF_MONTH:
setDayOfMonth((int) value);
break;
case HOUR:
setHour((int) value);
break;
case MINUTE:
setMinute((int) value);
break;
case SECOND:
setSecond((int) value);
break;
case MILLISECOND:
setMillisecond(value);
break;
default:
throw new RuntimeException();
}
return _localTimeOfEpoch;
} | [
"public",
"long",
"set",
"(",
"int",
"field",
",",
"long",
"value",
")",
"{",
"switch",
"(",
"field",
")",
"{",
"case",
"YEAR",
":",
"setYear",
"(",
"(",
"int",
")",
"value",
")",
";",
"break",
";",
"case",
"MONTH",
":",
"setMonth",
"(",
"(",
"in... | Sets values based on a field. | [
"Sets",
"values",
"based",
"on",
"a",
"field",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/util/QDate.java#L635-L671 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/util/QDate.java | QDate.printDate | public void printDate(WriteStreamOld os)
throws IOException
{
os.print(DAY_NAMES[(int) (_dayOfEpoch % 7 + 11) % 7]);
os.write(',');
os.write(' ');
os.print((_dayOfMonth + 1) / 10);
os.print((_dayOfMonth + 1) % 10);
os.write(' ');
os.print(MONTH_NAMES[(int) _month]);
os.write(' ');
os.print(_year);
os.write(' ');
os.print((_timeOfDay / 36000000) % 10);
os.print((_timeOfDay / 3600000) % 10);
os.write(':');
os.print((_timeOfDay / 600000) % 6);
os.print((_timeOfDay / 60000) % 10);
os.write(':');
os.print((_timeOfDay / 10000) % 6);
os.print((_timeOfDay / 1000) % 10);
if (_zoneName == null) {
os.print(" GMT");
return;
}
long offset = _zoneOffset;
if (offset < 0) {
os.write(' ');
os.write('-');
offset = - offset;
} else {
os.write(' ');
os.write('+');
}
os.print((offset / 36000000) % 10);
os.print((offset / 3600000) % 10);
os.print((offset / 600000) % 6);
os.print((offset / 60000) % 10);
os.write(' ');
os.write('(');
os.print(_zoneName);
os.write(')');
} | java | public void printDate(WriteStreamOld os)
throws IOException
{
os.print(DAY_NAMES[(int) (_dayOfEpoch % 7 + 11) % 7]);
os.write(',');
os.write(' ');
os.print((_dayOfMonth + 1) / 10);
os.print((_dayOfMonth + 1) % 10);
os.write(' ');
os.print(MONTH_NAMES[(int) _month]);
os.write(' ');
os.print(_year);
os.write(' ');
os.print((_timeOfDay / 36000000) % 10);
os.print((_timeOfDay / 3600000) % 10);
os.write(':');
os.print((_timeOfDay / 600000) % 6);
os.print((_timeOfDay / 60000) % 10);
os.write(':');
os.print((_timeOfDay / 10000) % 6);
os.print((_timeOfDay / 1000) % 10);
if (_zoneName == null) {
os.print(" GMT");
return;
}
long offset = _zoneOffset;
if (offset < 0) {
os.write(' ');
os.write('-');
offset = - offset;
} else {
os.write(' ');
os.write('+');
}
os.print((offset / 36000000) % 10);
os.print((offset / 3600000) % 10);
os.print((offset / 600000) % 6);
os.print((offset / 60000) % 10);
os.write(' ');
os.write('(');
os.print(_zoneName);
os.write(')');
} | [
"public",
"void",
"printDate",
"(",
"WriteStreamOld",
"os",
")",
"throws",
"IOException",
"{",
"os",
".",
"print",
"(",
"DAY_NAMES",
"[",
"(",
"int",
")",
"(",
"_dayOfEpoch",
"%",
"7",
"+",
"11",
")",
"%",
"7",
"]",
")",
";",
"os",
".",
"write",
"(... | Prints the date to a stream. | [
"Prints",
"the",
"date",
"to",
"a",
"stream",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/util/QDate.java#L740-L787 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/util/QDate.java | QDate.printISO8601 | public String printISO8601()
{
StringBuilder sb = new StringBuilder();
if (_year > 0) {
sb.append((_year / 1000) % 10);
sb.append((_year / 100) % 10);
sb.append((_year / 10) % 10);
sb.append(_year % 10);
sb.append('-');
sb.append(((_month + 1) / 10) % 10);
sb.append((_month + 1) % 10);
sb.append('-');
sb.append(((_dayOfMonth + 1) / 10) % 10);
sb.append((_dayOfMonth + 1) % 10);
}
long time = _timeOfDay / 1000;
long ms = _timeOfDay % 1000;
sb.append('T');
sb.append((time / 36000) % 10);
sb.append((time / 3600) % 10);
sb.append(':');
sb.append((time / 600) % 6);
sb.append((time / 60) % 10);
sb.append(':');
sb.append((time / 10) % 6);
sb.append((time / 1) % 10);
if (ms != 0) {
sb.append('.');
sb.append((ms / 100) % 10);
sb.append((ms / 10) % 10);
sb.append(ms % 10);
}
if (_zoneName == null) {
sb.append("Z");
return sb.toString();
}
// server/1471 - XXX: was commented out
long offset = _zoneOffset;
if (offset < 0) {
sb.append("-");
offset = - offset;
} else
sb.append("+");
sb.append((offset / 36000000) % 10);
sb.append((offset / 3600000) % 10);
sb.append(':');
sb.append((offset / 600000) % 6);
sb.append((offset / 60000) % 10);
return sb.toString();
} | java | public String printISO8601()
{
StringBuilder sb = new StringBuilder();
if (_year > 0) {
sb.append((_year / 1000) % 10);
sb.append((_year / 100) % 10);
sb.append((_year / 10) % 10);
sb.append(_year % 10);
sb.append('-');
sb.append(((_month + 1) / 10) % 10);
sb.append((_month + 1) % 10);
sb.append('-');
sb.append(((_dayOfMonth + 1) / 10) % 10);
sb.append((_dayOfMonth + 1) % 10);
}
long time = _timeOfDay / 1000;
long ms = _timeOfDay % 1000;
sb.append('T');
sb.append((time / 36000) % 10);
sb.append((time / 3600) % 10);
sb.append(':');
sb.append((time / 600) % 6);
sb.append((time / 60) % 10);
sb.append(':');
sb.append((time / 10) % 6);
sb.append((time / 1) % 10);
if (ms != 0) {
sb.append('.');
sb.append((ms / 100) % 10);
sb.append((ms / 10) % 10);
sb.append(ms % 10);
}
if (_zoneName == null) {
sb.append("Z");
return sb.toString();
}
// server/1471 - XXX: was commented out
long offset = _zoneOffset;
if (offset < 0) {
sb.append("-");
offset = - offset;
} else
sb.append("+");
sb.append((offset / 36000000) % 10);
sb.append((offset / 3600000) % 10);
sb.append(':');
sb.append((offset / 600000) % 6);
sb.append((offset / 60000) % 10);
return sb.toString();
} | [
"public",
"String",
"printISO8601",
"(",
")",
"{",
"StringBuilder",
"sb",
"=",
"new",
"StringBuilder",
"(",
")",
";",
"if",
"(",
"_year",
">",
"0",
")",
"{",
"sb",
".",
"append",
"(",
"(",
"_year",
"/",
"1000",
")",
"%",
"10",
")",
";",
"sb",
"."... | Prints the time in ISO 8601 | [
"Prints",
"the",
"time",
"in",
"ISO",
"8601"
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/util/QDate.java#L829-L889 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/util/QDate.java | QDate.printISO8601Date | public String printISO8601Date()
{
CharBuffer cb = new CharBuffer();
if (_year > 0) {
cb.append((_year / 1000) % 10);
cb.append((_year / 100) % 10);
cb.append((_year / 10) % 10);
cb.append(_year % 10);
cb.append('-');
cb.append(((_month + 1) / 10) % 10);
cb.append((_month + 1) % 10);
cb.append('-');
cb.append(((_dayOfMonth + 1) / 10) % 10);
cb.append((_dayOfMonth + 1) % 10);
}
return cb.toString();
} | java | public String printISO8601Date()
{
CharBuffer cb = new CharBuffer();
if (_year > 0) {
cb.append((_year / 1000) % 10);
cb.append((_year / 100) % 10);
cb.append((_year / 10) % 10);
cb.append(_year % 10);
cb.append('-');
cb.append(((_month + 1) / 10) % 10);
cb.append((_month + 1) % 10);
cb.append('-');
cb.append(((_dayOfMonth + 1) / 10) % 10);
cb.append((_dayOfMonth + 1) % 10);
}
return cb.toString();
} | [
"public",
"String",
"printISO8601Date",
"(",
")",
"{",
"CharBuffer",
"cb",
"=",
"new",
"CharBuffer",
"(",
")",
";",
"if",
"(",
"_year",
">",
"0",
")",
"{",
"cb",
".",
"append",
"(",
"(",
"_year",
"/",
"1000",
")",
"%",
"10",
")",
";",
"cb",
".",
... | Prints just the date component of ISO 8601 | [
"Prints",
"just",
"the",
"date",
"component",
"of",
"ISO",
"8601"
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/util/QDate.java#L894-L912 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/util/QDate.java | QDate.formatGMT | public synchronized static String formatGMT(long gmtTime, String format)
{
_gmtDate.setGMTTime(gmtTime);
return _gmtDate.format(new CharBuffer(), format).toString();
} | java | public synchronized static String formatGMT(long gmtTime, String format)
{
_gmtDate.setGMTTime(gmtTime);
return _gmtDate.format(new CharBuffer(), format).toString();
} | [
"public",
"synchronized",
"static",
"String",
"formatGMT",
"(",
"long",
"gmtTime",
",",
"String",
"format",
")",
"{",
"_gmtDate",
".",
"setGMTTime",
"(",
"gmtTime",
")",
";",
"return",
"_gmtDate",
".",
"format",
"(",
"new",
"CharBuffer",
"(",
")",
",",
"fo... | Formats a date.
@param time the time to format
@param format the format string | [
"Formats",
"a",
"date",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/util/QDate.java#L920-L925 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/util/QDate.java | QDate.format | public String format(String format)
{
CharBuffer cb = new CharBuffer();
return format(cb, format).close();
} | java | public String format(String format)
{
CharBuffer cb = new CharBuffer();
return format(cb, format).close();
} | [
"public",
"String",
"format",
"(",
"String",
"format",
")",
"{",
"CharBuffer",
"cb",
"=",
"new",
"CharBuffer",
"(",
")",
";",
"return",
"format",
"(",
"cb",
",",
"format",
")",
".",
"close",
"(",
")",
";",
"}"
] | Formats the current date. | [
"Formats",
"the",
"current",
"date",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/util/QDate.java#L1000-L1005 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/util/QDate.java | QDate.yearToDayOfEpoch | private long yearToDayOfEpoch(long year)
{
if (year > 0) {
year -= 1601;
return (365 * year + year / 4 - year / 100 + year / 400 -
((1970 - 1601) * 365 + (1970 - 1601) / 4 - 3));
} else {
year = 2000 - year;
return ((2000 - 1970) * 365 + (2000 - 1970) / 4 -
(365 * year + year / 4 - year / 100 + year / 400));
}
} | java | private long yearToDayOfEpoch(long year)
{
if (year > 0) {
year -= 1601;
return (365 * year + year / 4 - year / 100 + year / 400 -
((1970 - 1601) * 365 + (1970 - 1601) / 4 - 3));
} else {
year = 2000 - year;
return ((2000 - 1970) * 365 + (2000 - 1970) / 4 -
(365 * year + year / 4 - year / 100 + year / 400));
}
} | [
"private",
"long",
"yearToDayOfEpoch",
"(",
"long",
"year",
")",
"{",
"if",
"(",
"year",
">",
"0",
")",
"{",
"year",
"-=",
"1601",
";",
"return",
"(",
"365",
"*",
"year",
"+",
"year",
"/",
"4",
"-",
"year",
"/",
"100",
"+",
"year",
"/",
"400",
... | Based on the year, return the number of days since the epoch. | [
"Based",
"on",
"the",
"year",
"return",
"the",
"number",
"of",
"days",
"since",
"the",
"epoch",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/util/QDate.java#L1563-L1575 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/util/QDate.java | QDate.monthToDayOfYear | private long monthToDayOfYear(long month, boolean isLeapYear)
{
long day = 0;
for (int i = 0; i < month && i < 12; i++) {
day += DAYS_IN_MONTH[i];
if (i == 1 && isLeapYear)
day++;
}
return day;
} | java | private long monthToDayOfYear(long month, boolean isLeapYear)
{
long day = 0;
for (int i = 0; i < month && i < 12; i++) {
day += DAYS_IN_MONTH[i];
if (i == 1 && isLeapYear)
day++;
}
return day;
} | [
"private",
"long",
"monthToDayOfYear",
"(",
"long",
"month",
",",
"boolean",
"isLeapYear",
")",
"{",
"long",
"day",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<",
"month",
"&&",
"i",
"<",
"12",
";",
"i",
"++",
")",
"{",
"day",
... | Calculates the day of the year for the beginning of the month. | [
"Calculates",
"the",
"day",
"of",
"the",
"year",
"for",
"the",
"beginning",
"of",
"the",
"month",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/util/QDate.java#L1580-L1591 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/util/QDate.java | QDate.setDate | public long setDate(long year, long month, long day)
{
year += (long) Math.floor(month / 12.0);
month -= (long) 12 * Math.floor(month / 12.0);
_year = year;
_month = month;
_dayOfMonth = day - 1;
calculateJoin();
calculateSplit(_localTimeOfEpoch);
return _localTimeOfEpoch;
} | java | public long setDate(long year, long month, long day)
{
year += (long) Math.floor(month / 12.0);
month -= (long) 12 * Math.floor(month / 12.0);
_year = year;
_month = month;
_dayOfMonth = day - 1;
calculateJoin();
calculateSplit(_localTimeOfEpoch);
return _localTimeOfEpoch;
} | [
"public",
"long",
"setDate",
"(",
"long",
"year",
",",
"long",
"month",
",",
"long",
"day",
")",
"{",
"year",
"+=",
"(",
"long",
")",
"Math",
".",
"floor",
"(",
"month",
"/",
"12.0",
")",
";",
"month",
"-=",
"(",
"long",
")",
"12",
"*",
"Math",
... | Sets date in the local time.
@param year
@param month where January = 0
@param day day of month where the 1st = 1 | [
"Sets",
"date",
"in",
"the",
"local",
"time",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/util/QDate.java#L1689-L1702 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/util/QDate.java | QDate.calculateSplit | private void calculateSplit(long localTime)
{
_localTimeOfEpoch = localTime;
_dayOfEpoch = divFloor(_localTimeOfEpoch, MS_PER_DAY);
_timeOfDay = _localTimeOfEpoch - MS_PER_DAY * _dayOfEpoch;
calculateYear();
calculateMonth();
_hour = _timeOfDay / 3600000;
_minute = _timeOfDay / 60000 % 60;
_second = _timeOfDay / 1000 % 60;
_ms = _timeOfDay % 1000;
if (_timeZone == _gmtTimeZone) {
_isDaylightTime = false;
_zoneName = _stdName;
_zoneOffset = 0;
}
else {
// server/1470
long tempOffset = _timeZone.getOffset(_localTimeOfEpoch);
_zoneOffset = _timeZone.getOffset(_localTimeOfEpoch - tempOffset);
if (_zoneOffset == _timeZone.getRawOffset()) {
_isDaylightTime = false;
_zoneName = _stdName;
}
else {
_isDaylightTime = true;
_zoneName = _dstName;
}
}
_calendar.setTimeInMillis(_localTimeOfEpoch);
} | java | private void calculateSplit(long localTime)
{
_localTimeOfEpoch = localTime;
_dayOfEpoch = divFloor(_localTimeOfEpoch, MS_PER_DAY);
_timeOfDay = _localTimeOfEpoch - MS_PER_DAY * _dayOfEpoch;
calculateYear();
calculateMonth();
_hour = _timeOfDay / 3600000;
_minute = _timeOfDay / 60000 % 60;
_second = _timeOfDay / 1000 % 60;
_ms = _timeOfDay % 1000;
if (_timeZone == _gmtTimeZone) {
_isDaylightTime = false;
_zoneName = _stdName;
_zoneOffset = 0;
}
else {
// server/1470
long tempOffset = _timeZone.getOffset(_localTimeOfEpoch);
_zoneOffset = _timeZone.getOffset(_localTimeOfEpoch - tempOffset);
if (_zoneOffset == _timeZone.getRawOffset()) {
_isDaylightTime = false;
_zoneName = _stdName;
}
else {
_isDaylightTime = true;
_zoneName = _dstName;
}
}
_calendar.setTimeInMillis(_localTimeOfEpoch);
} | [
"private",
"void",
"calculateSplit",
"(",
"long",
"localTime",
")",
"{",
"_localTimeOfEpoch",
"=",
"localTime",
";",
"_dayOfEpoch",
"=",
"divFloor",
"(",
"_localTimeOfEpoch",
",",
"MS_PER_DAY",
")",
";",
"_timeOfDay",
"=",
"_localTimeOfEpoch",
"-",
"MS_PER_DAY",
"... | Calculate and set the calendar components based on the given time.
@param localTime local time in milliseconds since the epoch | [
"Calculate",
"and",
"set",
"the",
"calendar",
"components",
"based",
"on",
"the",
"given",
"time",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/util/QDate.java#L1722-L1757 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/util/QDate.java | QDate.calculateYear | private void calculateYear()
{
long days = _dayOfEpoch;
// shift to using 1601 as a base
days += (1970 - 1601) * 365 + (1970 - 1601) / 4 - 3;
long n400 = divFloor(days, 400 * 365 + 100 - 3);
days -= n400 * (400 * 365 + 100 - 3);
long n100 = divFloor(days, 100 * 365 + 25 - 1);
if (n100 == 4)
n100 = 3;
days -= n100 * (100 * 365 + 25 - 1);
long n4 = divFloor(days, 4 * 365 + 1);
if (n4 == 25)
n4 = 24;
days -= n4 * (4 * 365 + 1);
long n1 = divFloor(days, 365);
if (n1 == 4)
n1 = 3;
_year = 400 * n400 + 100 * n100 + 4 * n4 + n1 + 1601;
_dayOfYear = (int) (days - 365 * n1);
_isLeapYear = isLeapYear(_year);
} | java | private void calculateYear()
{
long days = _dayOfEpoch;
// shift to using 1601 as a base
days += (1970 - 1601) * 365 + (1970 - 1601) / 4 - 3;
long n400 = divFloor(days, 400 * 365 + 100 - 3);
days -= n400 * (400 * 365 + 100 - 3);
long n100 = divFloor(days, 100 * 365 + 25 - 1);
if (n100 == 4)
n100 = 3;
days -= n100 * (100 * 365 + 25 - 1);
long n4 = divFloor(days, 4 * 365 + 1);
if (n4 == 25)
n4 = 24;
days -= n4 * (4 * 365 + 1);
long n1 = divFloor(days, 365);
if (n1 == 4)
n1 = 3;
_year = 400 * n400 + 100 * n100 + 4 * n4 + n1 + 1601;
_dayOfYear = (int) (days - 365 * n1);
_isLeapYear = isLeapYear(_year);
} | [
"private",
"void",
"calculateYear",
"(",
")",
"{",
"long",
"days",
"=",
"_dayOfEpoch",
";",
"// shift to using 1601 as a base",
"days",
"+=",
"(",
"1970",
"-",
"1601",
")",
"*",
"365",
"+",
"(",
"1970",
"-",
"1601",
")",
"/",
"4",
"-",
"3",
";",
"long"... | Calculates the year, the dayOfYear and whether this is a leap year
from the current days since the epoch. | [
"Calculates",
"the",
"year",
"the",
"dayOfYear",
"and",
"whether",
"this",
"is",
"a",
"leap",
"year",
"from",
"the",
"current",
"days",
"since",
"the",
"epoch",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/util/QDate.java#L1763-L1791 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/util/QDate.java | QDate.calculateMonth | private void calculateMonth()
{
_dayOfMonth = _dayOfYear;
for (_month = 0; _month < 12; _month++) {
if (_month == 1 && _isLeapYear) {
if (_dayOfMonth < 29)
return;
else
_dayOfMonth -= 29;
}
else if (_dayOfMonth < DAYS_IN_MONTH[(int) _month])
return;
else
_dayOfMonth -= DAYS_IN_MONTH[(int) _month];
}
} | java | private void calculateMonth()
{
_dayOfMonth = _dayOfYear;
for (_month = 0; _month < 12; _month++) {
if (_month == 1 && _isLeapYear) {
if (_dayOfMonth < 29)
return;
else
_dayOfMonth -= 29;
}
else if (_dayOfMonth < DAYS_IN_MONTH[(int) _month])
return;
else
_dayOfMonth -= DAYS_IN_MONTH[(int) _month];
}
} | [
"private",
"void",
"calculateMonth",
"(",
")",
"{",
"_dayOfMonth",
"=",
"_dayOfYear",
";",
"for",
"(",
"_month",
"=",
"0",
";",
"_month",
"<",
"12",
";",
"_month",
"++",
")",
"{",
"if",
"(",
"_month",
"==",
"1",
"&&",
"_isLeapYear",
")",
"{",
"if",
... | Calculates the month based on the day of the year. | [
"Calculates",
"the",
"month",
"based",
"on",
"the",
"day",
"of",
"the",
"year",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/util/QDate.java#L1801-L1817 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/util/QDate.java | QDate.calculateJoin | private long calculateJoin()
{
_year += divFloor(_month, 12);
_month -= 12 * divFloor(_month, 12);
_localTimeOfEpoch
= MS_PER_DAY * (yearToDayOfEpoch(_year)
+ monthToDayOfYear(_month, isLeapYear(_year))
+ _dayOfMonth);
_localTimeOfEpoch += _ms + 1000 * (_second + 60 * (_minute + 60 * _hour));
return _localTimeOfEpoch;
} | java | private long calculateJoin()
{
_year += divFloor(_month, 12);
_month -= 12 * divFloor(_month, 12);
_localTimeOfEpoch
= MS_PER_DAY * (yearToDayOfEpoch(_year)
+ monthToDayOfYear(_month, isLeapYear(_year))
+ _dayOfMonth);
_localTimeOfEpoch += _ms + 1000 * (_second + 60 * (_minute + 60 * _hour));
return _localTimeOfEpoch;
} | [
"private",
"long",
"calculateJoin",
"(",
")",
"{",
"_year",
"+=",
"divFloor",
"(",
"_month",
",",
"12",
")",
";",
"_month",
"-=",
"12",
"*",
"divFloor",
"(",
"_month",
",",
"12",
")",
";",
"_localTimeOfEpoch",
"=",
"MS_PER_DAY",
"*",
"(",
"yearToDayOfEpo... | Based on the current data, calculate the time since the epoch.
@return time since the epoch, given the calendar components | [
"Based",
"on",
"the",
"current",
"data",
"calculate",
"the",
"time",
"since",
"the",
"epoch",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/util/QDate.java#L1824-L1837 | train |
baratine/baratine | framework/src/main/java/com/caucho/v5/vfs/BasicDependencyContainer.java | BasicDependencyContainer.logModified | public boolean logModified(Logger log)
{
for (int i = _dependencyList.size() - 1; i >= 0; i--) {
Dependency dependency = _dependencyList.get(i);
if (dependency.logModified(log))
return true;
}
return false;
} | java | public boolean logModified(Logger log)
{
for (int i = _dependencyList.size() - 1; i >= 0; i--) {
Dependency dependency = _dependencyList.get(i);
if (dependency.logModified(log))
return true;
}
return false;
} | [
"public",
"boolean",
"logModified",
"(",
"Logger",
"log",
")",
"{",
"for",
"(",
"int",
"i",
"=",
"_dependencyList",
".",
"size",
"(",
")",
"-",
"1",
";",
"i",
">=",
"0",
";",
"i",
"--",
")",
"{",
"Dependency",
"dependency",
"=",
"_dependencyList",
".... | Log the reason for the modification | [
"Log",
"the",
"reason",
"for",
"the",
"modification"
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/framework/src/main/java/com/caucho/v5/vfs/BasicDependencyContainer.java#L187-L197 | train |
baratine/baratine | kraken/src/main/java/com/caucho/v5/kelp/PageServiceImpl.java | PageServiceImpl.getSafe | @Override
public void getSafe(RowCursor cursor, Result<Boolean> result)
{
result.ok(getImpl(cursor));
} | java | @Override
public void getSafe(RowCursor cursor, Result<Boolean> result)
{
result.ok(getImpl(cursor));
} | [
"@",
"Override",
"public",
"void",
"getSafe",
"(",
"RowCursor",
"cursor",
",",
"Result",
"<",
"Boolean",
">",
"result",
")",
"{",
"result",
".",
"ok",
"(",
"getImpl",
"(",
"cursor",
")",
")",
";",
"}"
] | Non-peek get. | [
"Non",
"-",
"peek",
"get",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/PageServiceImpl.java#L211-L215 | train |
baratine/baratine | kraken/src/main/java/com/caucho/v5/kelp/PageServiceImpl.java | PageServiceImpl.getStream | @Direct
@Override
public void getStream(RowCursor cursor,
Result<GetStreamResult> result)
{
long version = cursor.getVersion();
PageLeafImpl leaf = getLeafByCursor(cursor);
if (leaf == null) {
result.ok(new GetStreamResult(false, null));
return;
}
if (! leaf.get(cursor)) {
result.ok(new GetStreamResult(false, null));
return;
}
if (version == cursor.getVersion()) {
result.ok(new GetStreamResult(true, null));
return;
}
StreamSource ss = leaf.getStream(cursor, this);
boolean isFound = ss != null;
result.ok(new GetStreamResult(isFound, ss));
} | java | @Direct
@Override
public void getStream(RowCursor cursor,
Result<GetStreamResult> result)
{
long version = cursor.getVersion();
PageLeafImpl leaf = getLeafByCursor(cursor);
if (leaf == null) {
result.ok(new GetStreamResult(false, null));
return;
}
if (! leaf.get(cursor)) {
result.ok(new GetStreamResult(false, null));
return;
}
if (version == cursor.getVersion()) {
result.ok(new GetStreamResult(true, null));
return;
}
StreamSource ss = leaf.getStream(cursor, this);
boolean isFound = ss != null;
result.ok(new GetStreamResult(isFound, ss));
} | [
"@",
"Direct",
"@",
"Override",
"public",
"void",
"getStream",
"(",
"RowCursor",
"cursor",
",",
"Result",
"<",
"GetStreamResult",
">",
"result",
")",
"{",
"long",
"version",
"=",
"cursor",
".",
"getVersion",
"(",
")",
";",
"PageLeafImpl",
"leaf",
"=",
"get... | For cluster calls, returns a stream to the new value if the value
has changed. | [
"For",
"cluster",
"calls",
"returns",
"a",
"stream",
"to",
"the",
"new",
"value",
"if",
"the",
"value",
"has",
"changed",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/PageServiceImpl.java#L232-L261 | train |
baratine/baratine | kraken/src/main/java/com/caucho/v5/kelp/PageServiceImpl.java | PageServiceImpl.getSequenceSize | long getSequenceSize(SegmentKelp segment)
{
int tailPid = _tailPid.get();
long size = 0;
for (int i = 0; i <= tailPid; i++) {
Page page = _pages.get(i);
if (page != null && page.getSegment() == segment) {
size += page.size();
}
}
return size;
} | java | long getSequenceSize(SegmentKelp segment)
{
int tailPid = _tailPid.get();
long size = 0;
for (int i = 0; i <= tailPid; i++) {
Page page = _pages.get(i);
if (page != null && page.getSegment() == segment) {
size += page.size();
}
}
return size;
} | [
"long",
"getSequenceSize",
"(",
"SegmentKelp",
"segment",
")",
"{",
"int",
"tailPid",
"=",
"_tailPid",
".",
"get",
"(",
")",
";",
"long",
"size",
"=",
"0",
";",
"for",
"(",
"int",
"i",
"=",
"0",
";",
"i",
"<=",
"tailPid",
";",
"i",
"++",
")",
"{"... | Returns the size in bytes of all pages with the given sequence.
Used by the page garbage-collector to determine which segments to
collect. | [
"Returns",
"the",
"size",
"in",
"bytes",
"of",
"all",
"pages",
"with",
"the",
"given",
"sequence",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/PageServiceImpl.java#L603-L618 | train |
baratine/baratine | kraken/src/main/java/com/caucho/v5/kelp/PageServiceImpl.java | PageServiceImpl.checkpoint | @Override
public void checkpoint(Result<Boolean> result)
{
if (! _journalStream.saveStart()) {
result.ok(true);
return;
}
TableWriterService readWrite = _table.getReadWrite();
// long limit = Integer.MAX_VALUE; // 128
int tailPid = _tailPid.get();
for (int pid = 1; pid <= tailPid; pid++) {
Page page = _pages.get(pid);
if (page != null) {
page.write(_table, this, readWrite);
}
}
readWrite.fsync(new CheckpointResult(result));
} | java | @Override
public void checkpoint(Result<Boolean> result)
{
if (! _journalStream.saveStart()) {
result.ok(true);
return;
}
TableWriterService readWrite = _table.getReadWrite();
// long limit = Integer.MAX_VALUE; // 128
int tailPid = _tailPid.get();
for (int pid = 1; pid <= tailPid; pid++) {
Page page = _pages.get(pid);
if (page != null) {
page.write(_table, this, readWrite);
}
}
readWrite.fsync(new CheckpointResult(result));
} | [
"@",
"Override",
"public",
"void",
"checkpoint",
"(",
"Result",
"<",
"Boolean",
">",
"result",
")",
"{",
"if",
"(",
"!",
"_journalStream",
".",
"saveStart",
"(",
")",
")",
"{",
"result",
".",
"ok",
"(",
"true",
")",
";",
"return",
";",
"}",
"TableWri... | Requests a checkpoint, flushing the in-memory data to disk. | [
"Requests",
"a",
"checkpoint",
"flushing",
"the",
"in",
"-",
"memory",
"data",
"to",
"disk",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/PageServiceImpl.java#L804-L825 | train |
baratine/baratine | kraken/src/main/java/com/caucho/v5/kelp/PageServiceImpl.java | PageServiceImpl.compareAndSetLeaf | boolean compareAndSetLeaf(Page oldPage, Page page)
{
if (oldPage == page) {
return true;
}
int pid = (int) page.getId();
updateTailPid(pid);
if (oldPage instanceof PageLeafImpl && page instanceof PageLeafImpl) {
PageLeafImpl oldLeaf = (PageLeafImpl) oldPage;
PageLeafImpl newLeaf = (PageLeafImpl) page;
if (BlockTree.compareKey(oldLeaf.getMaxKey(), newLeaf.getMaxKey(), 0) < 0) {
System.err.println(" DERP: " + oldPage + " " + page);
Thread.dumpStack();
/*
throw new IllegalStateException("DERP: old=" + oldPage + " " + page
+ " old-dirt:" + oldPage.isDirty());
*/
}
}
boolean result = _pages.compareAndSet(pid, oldPage, page);
return result;
} | java | boolean compareAndSetLeaf(Page oldPage, Page page)
{
if (oldPage == page) {
return true;
}
int pid = (int) page.getId();
updateTailPid(pid);
if (oldPage instanceof PageLeafImpl && page instanceof PageLeafImpl) {
PageLeafImpl oldLeaf = (PageLeafImpl) oldPage;
PageLeafImpl newLeaf = (PageLeafImpl) page;
if (BlockTree.compareKey(oldLeaf.getMaxKey(), newLeaf.getMaxKey(), 0) < 0) {
System.err.println(" DERP: " + oldPage + " " + page);
Thread.dumpStack();
/*
throw new IllegalStateException("DERP: old=" + oldPage + " " + page
+ " old-dirt:" + oldPage.isDirty());
*/
}
}
boolean result = _pages.compareAndSet(pid, oldPage, page);
return result;
} | [
"boolean",
"compareAndSetLeaf",
"(",
"Page",
"oldPage",
",",
"Page",
"page",
")",
"{",
"if",
"(",
"oldPage",
"==",
"page",
")",
"{",
"return",
"true",
";",
"}",
"int",
"pid",
"=",
"(",
"int",
")",
"page",
".",
"getId",
"(",
")",
";",
"updateTailPid",... | Updates the leaf to a new page.
Called only from TableService. | [
"Updates",
"the",
"leaf",
"to",
"a",
"new",
"page",
".",
"Called",
"only",
"from",
"TableService",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/PageServiceImpl.java#L970-L997 | train |
baratine/baratine | core/src/main/java/com/caucho/v5/loader/EnvLoader.java | EnvLoader.getDynamicClassLoader | public static DynamicClassLoader getDynamicClassLoader(ClassLoader loader)
{
for (; loader != null; loader = loader.getParent()) {
if (loader instanceof DynamicClassLoader) {
return (DynamicClassLoader) loader;
}
}
return null;
} | java | public static DynamicClassLoader getDynamicClassLoader(ClassLoader loader)
{
for (; loader != null; loader = loader.getParent()) {
if (loader instanceof DynamicClassLoader) {
return (DynamicClassLoader) loader;
}
}
return null;
} | [
"public",
"static",
"DynamicClassLoader",
"getDynamicClassLoader",
"(",
"ClassLoader",
"loader",
")",
"{",
"for",
"(",
";",
"loader",
"!=",
"null",
";",
"loader",
"=",
"loader",
".",
"getParent",
"(",
")",
")",
"{",
"if",
"(",
"loader",
"instanceof",
"Dynami... | Returns the topmost dynamic class loader.
@param loader the context loader | [
"Returns",
"the",
"topmost",
"dynamic",
"class",
"loader",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/loader/EnvLoader.java#L489-L498 | train |
baratine/baratine | core/src/main/java/com/caucho/v5/loader/EnvLoader.java | EnvLoader.setConfigException | public static void setConfigException(Throwable e)
{
ClassLoader loader = Thread.currentThread().getContextClassLoader();
for (; loader != null; loader = loader.getParent()) {
if (loader instanceof EnvironmentClassLoader) {
EnvironmentClassLoader envLoader = (EnvironmentClassLoader) loader;
envLoader.setConfigException(e);
return;
}
}
} | java | public static void setConfigException(Throwable e)
{
ClassLoader loader = Thread.currentThread().getContextClassLoader();
for (; loader != null; loader = loader.getParent()) {
if (loader instanceof EnvironmentClassLoader) {
EnvironmentClassLoader envLoader = (EnvironmentClassLoader) loader;
envLoader.setConfigException(e);
return;
}
}
} | [
"public",
"static",
"void",
"setConfigException",
"(",
"Throwable",
"e",
")",
"{",
"ClassLoader",
"loader",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
";",
"for",
"(",
";",
"loader",
"!=",
"null",
";",
"loader",
... | Sets a configuration exception. | [
"Sets",
"a",
"configuration",
"exception",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/loader/EnvLoader.java#L749-L762 | train |
baratine/baratine | core/src/main/java/com/caucho/v5/loader/EnvLoader.java | EnvLoader.getConfigException | public static Throwable getConfigException()
{
ClassLoader loader = Thread.currentThread().getContextClassLoader();
for (; loader != null; loader = loader.getParent()) {
if (loader instanceof EnvironmentClassLoader) {
EnvironmentClassLoader envLoader = (EnvironmentClassLoader) loader;
if (envLoader.getConfigException() != null)
return envLoader.getConfigException();
}
}
return null;
} | java | public static Throwable getConfigException()
{
ClassLoader loader = Thread.currentThread().getContextClassLoader();
for (; loader != null; loader = loader.getParent()) {
if (loader instanceof EnvironmentClassLoader) {
EnvironmentClassLoader envLoader = (EnvironmentClassLoader) loader;
if (envLoader.getConfigException() != null)
return envLoader.getConfigException();
}
}
return null;
} | [
"public",
"static",
"Throwable",
"getConfigException",
"(",
")",
"{",
"ClassLoader",
"loader",
"=",
"Thread",
".",
"currentThread",
"(",
")",
".",
"getContextClassLoader",
"(",
")",
";",
"for",
"(",
";",
"loader",
"!=",
"null",
";",
"loader",
"=",
"loader",
... | Returns any configuration exception. | [
"Returns",
"any",
"configuration",
"exception",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/loader/EnvLoader.java#L767-L781 | train |
baratine/baratine | core/src/main/java/com/caucho/v5/loader/EnvLoader.java | EnvLoader.getLocalClassPath | public static String getLocalClassPath(ClassLoader loader)
{
for (; loader != null; loader = loader.getParent()) {
if (loader instanceof EnvironmentClassLoader) {
return ((EnvironmentClassLoader) loader).getLocalClassPath();
}
}
return DynamicClassLoader.getSystemClassPath();
} | java | public static String getLocalClassPath(ClassLoader loader)
{
for (; loader != null; loader = loader.getParent()) {
if (loader instanceof EnvironmentClassLoader) {
return ((EnvironmentClassLoader) loader).getLocalClassPath();
}
}
return DynamicClassLoader.getSystemClassPath();
} | [
"public",
"static",
"String",
"getLocalClassPath",
"(",
"ClassLoader",
"loader",
")",
"{",
"for",
"(",
";",
"loader",
"!=",
"null",
";",
"loader",
"=",
"loader",
".",
"getParent",
"(",
")",
")",
"{",
"if",
"(",
"loader",
"instanceof",
"EnvironmentClassLoader... | Returns the classpath for the environment level. | [
"Returns",
"the",
"classpath",
"for",
"the",
"environment",
"level",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/loader/EnvLoader.java#L854-L863 | train |
baratine/baratine | core/src/main/java/com/caucho/v5/loader/EnvLoader.java | EnvLoader.closeGlobal | public static void closeGlobal()
{
ArrayList<EnvLoaderListener> listeners;
listeners = new ArrayList<>();
listeners.addAll(_globalLoaderListeners);
_globalLoaderListeners.clear();
for (int i = 0; i < listeners.size(); i++) {
EnvLoaderListener listener = listeners.get(i);
listener.classLoaderDestroy(null);
}
} | java | public static void closeGlobal()
{
ArrayList<EnvLoaderListener> listeners;
listeners = new ArrayList<>();
listeners.addAll(_globalLoaderListeners);
_globalLoaderListeners.clear();
for (int i = 0; i < listeners.size(); i++) {
EnvLoaderListener listener = listeners.get(i);
listener.classLoaderDestroy(null);
}
} | [
"public",
"static",
"void",
"closeGlobal",
"(",
")",
"{",
"ArrayList",
"<",
"EnvLoaderListener",
">",
"listeners",
";",
"listeners",
"=",
"new",
"ArrayList",
"<>",
"(",
")",
";",
"listeners",
".",
"addAll",
"(",
"_globalLoaderListeners",
")",
";",
"_globalLoad... | destroys the current environment. | [
"destroys",
"the",
"current",
"environment",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/loader/EnvLoader.java#L868-L880 | train |
baratine/baratine | core/src/main/java/com/caucho/v5/loader/EnvLoader.java | EnvLoader.initializeEnvironment | public static synchronized void initializeEnvironment()
{
if (_isStaticInit)
return;
_isStaticInit = true;
ClassLoader systemLoader = ClassLoader.getSystemClassLoader();
Thread thread = Thread.currentThread();
ClassLoader oldLoader = thread.getContextClassLoader();
try {
thread.setContextClassLoader(systemLoader);
if ("1.8.".compareTo(System.getProperty("java.runtime.version")) > 0)
throw new ConfigException("Baratine requires JDK 1.8 or later");
// #2281
// PolicyImpl.init();
//EnvironmentStream.setStdout(System.out);
//EnvironmentStream.setStderr(System.err);
/*
try {
Vfs.initJNI();
} catch (Throwable e) {
}
*/
Properties props = System.getProperties();
ClassLoader envClassLoader
= EnvironmentClassLoader.class.getClassLoader();
/*
boolean isGlobalLoadableJndi = false;
try {
Class<?> cl = Class.forName("com.caucho.v5.naming.InitialContextFactoryImpl",
false,
systemLoader);
isGlobalLoadableJndi = (cl != null);
} catch (Exception e) {
log().log(Level.FINER, e.toString(), e);
}
// #3486
String namingPkgs = (String) props.get("java.naming.factory.url.pkgs");
if (namingPkgs == null)
namingPkgs = "com.caucho.v5.naming";
else
namingPkgs = namingPkgs + ":" + "com.caucho.v5.naming";
props.put("java.naming.factory.url.pkgs", namingPkgs);
if (isGlobalLoadableJndi) {
// These properties require the server to be at the system loader
if (props.get("java.naming.factory.initial") == null) {
props.put("java.naming.factory.initial",
"com.caucho.v5.naming.InitialContextFactoryImpl");
}
}
*/
/*
boolean isGlobalLoadableJmx = false;
try {
Class<?> cl = Class.forName("com.caucho.v5.jmx.MBeanServerBuilderImpl",
false,
systemLoader);
isGlobalLoadableJmx = (cl != null);
} catch (Exception e) {
log().log(Level.FINER, e.toString(), e);
}
if (isGlobalLoadableJmx) {
// props.put("java.naming.factory.url.pkgs", "com.caucho.naming");
EnvironmentProperties.enableEnvironmentSystemProperties(true);
String oldBuilder = props.getProperty("javax.management.builder.initial");
if (oldBuilder == null) {
oldBuilder = "com.caucho.v5.jmx.MBeanServerBuilderImpl";
props.put("javax.management.builder.initial", oldBuilder);
}
Object value = ManagementFactory.getPlatformMBeanServer();
}
*/
} catch (Throwable e) {
log().log(Level.FINE, e.toString(), e);
} finally {
thread.setContextClassLoader(oldLoader);
_isInitComplete = true;
}
} | java | public static synchronized void initializeEnvironment()
{
if (_isStaticInit)
return;
_isStaticInit = true;
ClassLoader systemLoader = ClassLoader.getSystemClassLoader();
Thread thread = Thread.currentThread();
ClassLoader oldLoader = thread.getContextClassLoader();
try {
thread.setContextClassLoader(systemLoader);
if ("1.8.".compareTo(System.getProperty("java.runtime.version")) > 0)
throw new ConfigException("Baratine requires JDK 1.8 or later");
// #2281
// PolicyImpl.init();
//EnvironmentStream.setStdout(System.out);
//EnvironmentStream.setStderr(System.err);
/*
try {
Vfs.initJNI();
} catch (Throwable e) {
}
*/
Properties props = System.getProperties();
ClassLoader envClassLoader
= EnvironmentClassLoader.class.getClassLoader();
/*
boolean isGlobalLoadableJndi = false;
try {
Class<?> cl = Class.forName("com.caucho.v5.naming.InitialContextFactoryImpl",
false,
systemLoader);
isGlobalLoadableJndi = (cl != null);
} catch (Exception e) {
log().log(Level.FINER, e.toString(), e);
}
// #3486
String namingPkgs = (String) props.get("java.naming.factory.url.pkgs");
if (namingPkgs == null)
namingPkgs = "com.caucho.v5.naming";
else
namingPkgs = namingPkgs + ":" + "com.caucho.v5.naming";
props.put("java.naming.factory.url.pkgs", namingPkgs);
if (isGlobalLoadableJndi) {
// These properties require the server to be at the system loader
if (props.get("java.naming.factory.initial") == null) {
props.put("java.naming.factory.initial",
"com.caucho.v5.naming.InitialContextFactoryImpl");
}
}
*/
/*
boolean isGlobalLoadableJmx = false;
try {
Class<?> cl = Class.forName("com.caucho.v5.jmx.MBeanServerBuilderImpl",
false,
systemLoader);
isGlobalLoadableJmx = (cl != null);
} catch (Exception e) {
log().log(Level.FINER, e.toString(), e);
}
if (isGlobalLoadableJmx) {
// props.put("java.naming.factory.url.pkgs", "com.caucho.naming");
EnvironmentProperties.enableEnvironmentSystemProperties(true);
String oldBuilder = props.getProperty("javax.management.builder.initial");
if (oldBuilder == null) {
oldBuilder = "com.caucho.v5.jmx.MBeanServerBuilderImpl";
props.put("javax.management.builder.initial", oldBuilder);
}
Object value = ManagementFactory.getPlatformMBeanServer();
}
*/
} catch (Throwable e) {
log().log(Level.FINE, e.toString(), e);
} finally {
thread.setContextClassLoader(oldLoader);
_isInitComplete = true;
}
} | [
"public",
"static",
"synchronized",
"void",
"initializeEnvironment",
"(",
")",
"{",
"if",
"(",
"_isStaticInit",
")",
"return",
";",
"_isStaticInit",
"=",
"true",
";",
"ClassLoader",
"systemLoader",
"=",
"ClassLoader",
".",
"getSystemClassLoader",
"(",
")",
";",
... | Initializes the environment | [
"Initializes",
"the",
"environment"
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/core/src/main/java/com/caucho/v5/loader/EnvLoader.java#L905-L1003 | train |
SeaCloudsEU/SeaCloudsPlatform | sla/sla-core/sla-personalization/src/main/java/eu/atos/sla/modaclouds/ViolationSubscriber.java | ViolationSubscriber.buildRelatedRule | private MonitoringRule buildRelatedRule(IGuaranteeTerm guarantee) {
MonitoringRule result = new MonitoringRule();
result.setId(guarantee.getName());
String violation = extractOutputMetric(guarantee);
Parameter param = new Parameter();
param.setName(QosModels.METRIC_PARAM_NAME);
param.setValue(violation);
Action action = new Action();
action.setName(QosModels.OUTPUT_METRIC_ACTION);
action.getParameters().add(param);
Actions actions = new Actions();
actions.getActions().add(action);
result.setActions(actions);
return result;
} | java | private MonitoringRule buildRelatedRule(IGuaranteeTerm guarantee) {
MonitoringRule result = new MonitoringRule();
result.setId(guarantee.getName());
String violation = extractOutputMetric(guarantee);
Parameter param = new Parameter();
param.setName(QosModels.METRIC_PARAM_NAME);
param.setValue(violation);
Action action = new Action();
action.setName(QosModels.OUTPUT_METRIC_ACTION);
action.getParameters().add(param);
Actions actions = new Actions();
actions.getActions().add(action);
result.setActions(actions);
return result;
} | [
"private",
"MonitoringRule",
"buildRelatedRule",
"(",
"IGuaranteeTerm",
"guarantee",
")",
"{",
"MonitoringRule",
"result",
"=",
"new",
"MonitoringRule",
"(",
")",
";",
"result",
".",
"setId",
"(",
"guarantee",
".",
"getName",
"(",
")",
")",
";",
"String",
"vio... | Build a MonitoringRule given a guarantee term | [
"Build",
"a",
"MonitoringRule",
"given",
"a",
"guarantee",
"term"
] | b199fe6de2c63b808cb248d3aca947d802375df8 | https://github.com/SeaCloudsEU/SeaCloudsPlatform/blob/b199fe6de2c63b808cb248d3aca947d802375df8/sla/sla-core/sla-personalization/src/main/java/eu/atos/sla/modaclouds/ViolationSubscriber.java#L113-L133 | train |
baratine/baratine | kraken/src/main/java/com/caucho/v5/kelp/DebugKelp.java | DebugKelp.debug | public void debug(WriteStream out, Path path, byte []tableKey)
throws IOException
{
SegmentKelpBuilder builder = new SegmentKelpBuilder();
builder.path(path);
builder.create(false);
builder.services(ServicesAmp.newManager().get());
SegmentServiceImpl segmentService = builder.build();
for (SegmentExtent extent : segmentService.getSegmentExtents()) {
debugSegment(out, segmentService, extent, tableKey);
}
} | java | public void debug(WriteStream out, Path path, byte []tableKey)
throws IOException
{
SegmentKelpBuilder builder = new SegmentKelpBuilder();
builder.path(path);
builder.create(false);
builder.services(ServicesAmp.newManager().get());
SegmentServiceImpl segmentService = builder.build();
for (SegmentExtent extent : segmentService.getSegmentExtents()) {
debugSegment(out, segmentService, extent, tableKey);
}
} | [
"public",
"void",
"debug",
"(",
"WriteStream",
"out",
",",
"Path",
"path",
",",
"byte",
"[",
"]",
"tableKey",
")",
"throws",
"IOException",
"{",
"SegmentKelpBuilder",
"builder",
"=",
"new",
"SegmentKelpBuilder",
"(",
")",
";",
"builder",
".",
"path",
"(",
... | Debug with a table key
@param out the result of the debug stream
@param path the database source
@param tableKey the specific table to display
@throws IOException | [
"Debug",
"with",
"a",
"table",
"key"
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/DebugKelp.java#L110-L123 | train |
baratine/baratine | kraken/src/main/java/com/caucho/v5/kelp/DebugKelp.java | DebugKelp.debugSegment | private void debugSegment(WriteStream out,
SegmentServiceImpl segmentService,
SegmentExtent extent,
byte []debugTableKey)
throws IOException
{
int length = extent.length();
try (InSegment in = segmentService.openRead(extent)) {
ReadStream is = new ReadStream(in);
is.position(length - BLOCK_SIZE);
long seq = BitsUtil.readLong(is);
if (seq <= 0) {
return;
}
byte []tableKey = new byte[32];
is.readAll(tableKey, 0, tableKey.length);
TableEntry table = segmentService.findTable(tableKey);
if (table == null) {
return;
}
if (debugTableKey != null && ! Arrays.equals(debugTableKey, tableKey)) {
return;
}
out.println();
StringBuilder sb = new StringBuilder();
Base64Util.encode(sb, seq);
long time = _idGen.time(seq);
out.println("Segment: " + extent.getId() + " (seq: " + sb
+ ", table: " + Hex.toShortHex(tableKey)
+ ", addr: 0x" + Long.toHexString(extent.address())
+ ", len: 0x" + Integer.toHexString(length)
+ ", time: " + LocalDateTime.ofEpochSecond(time / 1000, 0, ZoneOffset.UTC)
+ ")");
debugSegmentEntries(out, is, extent, table);
}
} | java | private void debugSegment(WriteStream out,
SegmentServiceImpl segmentService,
SegmentExtent extent,
byte []debugTableKey)
throws IOException
{
int length = extent.length();
try (InSegment in = segmentService.openRead(extent)) {
ReadStream is = new ReadStream(in);
is.position(length - BLOCK_SIZE);
long seq = BitsUtil.readLong(is);
if (seq <= 0) {
return;
}
byte []tableKey = new byte[32];
is.readAll(tableKey, 0, tableKey.length);
TableEntry table = segmentService.findTable(tableKey);
if (table == null) {
return;
}
if (debugTableKey != null && ! Arrays.equals(debugTableKey, tableKey)) {
return;
}
out.println();
StringBuilder sb = new StringBuilder();
Base64Util.encode(sb, seq);
long time = _idGen.time(seq);
out.println("Segment: " + extent.getId() + " (seq: " + sb
+ ", table: " + Hex.toShortHex(tableKey)
+ ", addr: 0x" + Long.toHexString(extent.address())
+ ", len: 0x" + Integer.toHexString(length)
+ ", time: " + LocalDateTime.ofEpochSecond(time / 1000, 0, ZoneOffset.UTC)
+ ")");
debugSegmentEntries(out, is, extent, table);
}
} | [
"private",
"void",
"debugSegment",
"(",
"WriteStream",
"out",
",",
"SegmentServiceImpl",
"segmentService",
",",
"SegmentExtent",
"extent",
",",
"byte",
"[",
"]",
"debugTableKey",
")",
"throws",
"IOException",
"{",
"int",
"length",
"=",
"extent",
".",
"length",
"... | Trace through a segment, displaying its sequence, table, and extent. | [
"Trace",
"through",
"a",
"segment",
"displaying",
"its",
"sequence",
"table",
"and",
"extent",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/DebugKelp.java#L128-L175 | train |
baratine/baratine | kraken/src/main/java/com/caucho/v5/kelp/DebugKelp.java | DebugKelp.debugSegmentEntries | private void debugSegmentEntries(WriteStream out,
ReadStream is,
SegmentExtent extent,
TableEntry table)
throws IOException
{
TempBuffer tBuf = TempBuffer.create();
byte []buffer = tBuf.buffer();
for (long ptr = extent.length() - BLOCK_SIZE;
ptr > 0;
ptr -= BLOCK_SIZE) {
is.position(ptr);
is.readAll(buffer, 0, BLOCK_SIZE);
long seq = BitsUtil.readLong(buffer, 0);
int head = 8;
byte []tableKey = new byte[32];
System.arraycopy(buffer, head, tableKey, 0, tableKey.length);
is.readAll(tableKey, 0, tableKey.length);
head += tableKey.length;
int offset = BLOCK_SIZE - 8;
int tail = BitsUtil.readInt16(buffer, offset);
offset += 2;
boolean isCont = buffer[offset] == 1;
if (seq <= 0 || tail <= 0) {
return;
}
while ((head = debugSegmentIndex(out, is, buffer, extent.address(),
ptr, head,
table)) < tail) {
}
if (! isCont) {
break;
}
}
} | java | private void debugSegmentEntries(WriteStream out,
ReadStream is,
SegmentExtent extent,
TableEntry table)
throws IOException
{
TempBuffer tBuf = TempBuffer.create();
byte []buffer = tBuf.buffer();
for (long ptr = extent.length() - BLOCK_SIZE;
ptr > 0;
ptr -= BLOCK_SIZE) {
is.position(ptr);
is.readAll(buffer, 0, BLOCK_SIZE);
long seq = BitsUtil.readLong(buffer, 0);
int head = 8;
byte []tableKey = new byte[32];
System.arraycopy(buffer, head, tableKey, 0, tableKey.length);
is.readAll(tableKey, 0, tableKey.length);
head += tableKey.length;
int offset = BLOCK_SIZE - 8;
int tail = BitsUtil.readInt16(buffer, offset);
offset += 2;
boolean isCont = buffer[offset] == 1;
if (seq <= 0 || tail <= 0) {
return;
}
while ((head = debugSegmentIndex(out, is, buffer, extent.address(),
ptr, head,
table)) < tail) {
}
if (! isCont) {
break;
}
}
} | [
"private",
"void",
"debugSegmentEntries",
"(",
"WriteStream",
"out",
",",
"ReadStream",
"is",
",",
"SegmentExtent",
"extent",
",",
"TableEntry",
"table",
")",
"throws",
"IOException",
"{",
"TempBuffer",
"tBuf",
"=",
"TempBuffer",
".",
"create",
"(",
")",
";",
... | Trace through the segment entries. | [
"Trace",
"through",
"the",
"segment",
"entries",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/DebugKelp.java#L180-L222 | train |
baratine/baratine | kraken/src/main/java/com/caucho/v5/kelp/DebugKelp.java | DebugKelp.debugSegmentIndex | private int debugSegmentIndex(WriteStream out,
ReadStream is,
byte []buffer,
long segmentAddress,
long ptr,
int head,
TableEntry table)
throws IOException
{
int sublen = 1 + 4 * 4;
//tail -= sublen;
// is.position(ptr + tail);
int typeCode = buffer[head] & 0xff;
head++;
if (typeCode <= 0) {
return 0;
}
Type type = Type.valueOf(typeCode);
int pid = BitsUtil.readInt(buffer, head);
head += 4;
int nextPid = BitsUtil.readInt(buffer, head);
head += 4;
int offset = BitsUtil.readInt(buffer, head);
head += 4;
int length = BitsUtil.readInt(buffer, head);
head += 4;
switch (type) {
case LEAF:
out.print(" " + type);
debugLeaf(out, is, segmentAddress, offset, table);
break;
case LEAF_DELTA:
out.print(" " + type);
break;
case BLOB:
case BLOB_FREE:
out.print(" " + type);
break;
default:
out.print(" unk(" + type + ")");
break;
}
// is.position(pos);
out.println(" pid:" + pid + " next:" + nextPid
+ " offset:" + offset + " length:" + length);
return head;
} | java | private int debugSegmentIndex(WriteStream out,
ReadStream is,
byte []buffer,
long segmentAddress,
long ptr,
int head,
TableEntry table)
throws IOException
{
int sublen = 1 + 4 * 4;
//tail -= sublen;
// is.position(ptr + tail);
int typeCode = buffer[head] & 0xff;
head++;
if (typeCode <= 0) {
return 0;
}
Type type = Type.valueOf(typeCode);
int pid = BitsUtil.readInt(buffer, head);
head += 4;
int nextPid = BitsUtil.readInt(buffer, head);
head += 4;
int offset = BitsUtil.readInt(buffer, head);
head += 4;
int length = BitsUtil.readInt(buffer, head);
head += 4;
switch (type) {
case LEAF:
out.print(" " + type);
debugLeaf(out, is, segmentAddress, offset, table);
break;
case LEAF_DELTA:
out.print(" " + type);
break;
case BLOB:
case BLOB_FREE:
out.print(" " + type);
break;
default:
out.print(" unk(" + type + ")");
break;
}
// is.position(pos);
out.println(" pid:" + pid + " next:" + nextPid
+ " offset:" + offset + " length:" + length);
return head;
} | [
"private",
"int",
"debugSegmentIndex",
"(",
"WriteStream",
"out",
",",
"ReadStream",
"is",
",",
"byte",
"[",
"]",
"buffer",
",",
"long",
"segmentAddress",
",",
"long",
"ptr",
",",
"int",
"head",
",",
"TableEntry",
"table",
")",
"throws",
"IOException",
"{",
... | Debug a single segment index entry. | [
"Debug",
"a",
"single",
"segment",
"index",
"entry",
"."
] | db34b45c03c5a5e930d8142acc72319125569fcf | https://github.com/baratine/baratine/blob/db34b45c03c5a5e930d8142acc72319125569fcf/kraken/src/main/java/com/caucho/v5/kelp/DebugKelp.java#L227-L285 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.