code stringlengths 73 34.1k | label stringclasses 1
value |
|---|---|
public void write(final Writer outputWriter) throws IOException {
try (final DataInputStream keyStream = entry.getKeyStream();
final DataInputStream valueStream = entry.getValueStream();) {
outputWriter.write("Container: ");
outputWriter.write(keyStream.readUTF());
outputWriter.write("\n"... | java |
public void write(final File folder) throws IOException {
try (final DataInputStream keyStream = entry.getKeyStream();
final DataInputStream valueStream = entry.getValueStream();) {
final String containerId = keyStream.readUTF();
try (final Writer outputWriter = new OutputStreamWriter(
... | java |
private void writeFiles(final DataInputStream valueStream, final Writer outputWriter) throws IOException {
while (valueStream.available() > 0) {
final String strFileName = valueStream.readUTF();
final int entryLength = Integer.parseInt(valueStream.readUTF());
outputWriter.write("==================... | java |
private void write(final DataInputStream stream, final Writer outputWriter, final int numberOfBytes)
throws IOException {
final byte[] buf = new byte[65535];
int lenRemaining = numberOfBytes;
while (lenRemaining > 0) {
final int len = stream.read(buf, 0, lenRemaining > 65535 ? 65535 : lenRemaini... | java |
@Override
public void set(final String name, final UserCredentials hostUser) throws IOException {
assert this.proxyUGI == null;
assert hostUser instanceof YarnProxyUser;
LOG.log(Level.FINE, "UGI: user {0} copy from: {1}", new Object[] {name, hostUser});
final UserGroupInformation hostUGI = ((YarnPr... | java |
@SafeVarargs
public final void set(final String proxyName,
final UserGroupInformation hostUGI, final Token<? extends TokenIdentifier>... tokens) {
assert this.proxyUGI == null;
this.proxyUGI = UserGroupInformation.createProxyUser(proxyName, hostUGI);
for (final Token<? extends TokenIdentifier> tok... | java |
public <T> T doAs(final PrivilegedExceptionAction<T> action) throws Exception {
LOG.log(Level.FINE, "{0} execute {1}", new Object[] {this, action});
return this.proxyUGI == null ? action.run() : this.proxyUGI.doAs(action);
} | java |
@Override
public byte[] call(final byte[] memento) {
LOG.log(Level.FINE, "Task started: sleep for: {0} msec.", this.delay);
final long ts = System.currentTimeMillis();
for (long period = this.delay; period > 0; period -= System.currentTimeMillis() - ts) {
try {
Thread.sleep(period);
} ... | java |
JobSubmissionEventImpl.Builder getJobSubmissionBuilder(final Configuration driverConfiguration)
throws InjectionException, IOException {
final Injector injector = Tang.Factory.getTang().newInjector(driverConfiguration);
final boolean preserveEvaluators = injector.getNamedInstance(ResourceManagerPreserveE... | java |
private static FileResource getFileResourceProto(final String fileName, final FileType type) throws IOException {
File file = new File(fileName);
if (file.exists()) {
// It is a local file and can be added.
if (file.isDirectory()) {
// If it is a directory, create a JAR file of it and add th... | java |
private static File toJar(final File file) throws IOException {
final File tempFolder = Files.createTempDirectory("reef-tmp-tempFolder").toFile();
final File jarFile = File.createTempFile(file.getCanonicalFile().getName(), ".jar", tempFolder);
LOG.log(Level.FINEST, "Adding contents of folder {0} to {1}", ne... | java |
private static Throwable getThrowable(final RuntimeErrorProto error) {
final byte[] data = getData(error);
if (data != null) {
try {
return CODEC.decode(data);
} catch (final RemoteRuntimeException ex) {
LOG.log(Level.FINE, "Could not decode exception {0}: {1}", new Object[]{error, e... | java |
public ApplicationID getApplicationID() throws IOException {
final String url = "ws/v1/cluster/apps/new-application";
final HttpPost post = preparePost(url);
try (final CloseableHttpResponse response = this.httpClient.execute(post, this.httpClientContext)) {
final String message = IOUtils.toString(res... | java |
public void submitApplication(final ApplicationSubmission applicationSubmission) throws IOException {
final String url = "ws/v1/cluster/apps";
final HttpPost post = preparePost(url);
final StringWriter writer = new StringWriter();
try {
this.objectMapper.writeValue(writer, applicationSubmission);... | java |
public void killApplication(final String applicationId) throws IOException {
final String url = this.getApplicationURL(applicationId) + "/state";
final HttpPut put = preparePut(url);
put.setEntity(new StringEntity(APPLICATION_KILL_MESSAGE, ContentType.APPLICATION_JSON));
this.httpClient.execute(put, thi... | java |
public ApplicationState getApplication(final String applicationId) throws IOException {
final String url = this.getApplicationURL(applicationId);
final HttpGet get = prepareGet(url);
try (final CloseableHttpResponse response = this.httpClient.execute(get, this.httpClientContext)) {
final String messag... | java |
private HttpGet prepareGet(final String url) {
final HttpGet httpGet = new HttpGet(this.instanceUrl + url);
for (final Header header : this.headers) {
httpGet.addHeader(header);
}
return httpGet;
} | java |
private HttpPost preparePost(final String url) {
final HttpPost httpPost = new HttpPost(this.instanceUrl + url);
for (final Header header : this.headers) {
httpPost.addHeader(header);
}
return httpPost;
} | java |
private HttpPut preparePut(final String url) {
final HttpPut httpPut = new HttpPut(this.instanceUrl + url);
for (final Header header : this.headers) {
httpPut.addHeader(header);
}
return httpPut;
} | java |
@Override
public void onNext(final Alarm alarm) {
String jobId = this.azureBatchHelper.getAzureBatchJobId();
List<CloudTask> allTasks = this.azureBatchHelper.getTaskStatusForJob(jobId);
// Report status if the task has an associated active container.
LOG.log(Level.FINER, "Found {0} tasks from job id ... | java |
public synchronized void enableAlarm() {
if (!this.isAlarmEnabled) {
LOG.log(Level.FINE, "Enabling the alarm and scheduling it to fire in {0} ms.", this.taskStatusCheckPeriod);
this.isAlarmEnabled = true;
this.scheduleAlarm();
} else {
LOG.log(Level.FINE, "Alarm is already enabled.");
... | java |
public synchronized int submitCommand(final String command) {
final Integer id = scheduler.assignTaskId();
scheduler.addTask(new TaskEntity(id, command));
if (state == State.READY) {
notify(); // Wake up at {waitForCommands}
} else if (state == State.RUNNING && nMaxEval > nActiveEval + nRequested... | java |
public synchronized int setMaxEvaluators(final int targetNum) throws UnsuccessfulException {
if (targetNum < nActiveEval + nRequestedEval) {
throw new UnsuccessfulException(nActiveEval + nRequestedEval +
" evaluators are used now. Should be larger than that.");
}
nMaxEval = targetNum;
i... | java |
private synchronized void requestEvaluator(final int numToRequest) {
if (numToRequest <= 0) {
throw new IllegalArgumentException("The number of evaluator request should be a positive integer");
}
nRequestedEval += numToRequest;
requestor.newRequest()
.setMemory(32)
.setNumber(numT... | java |
private synchronized void waitForCommands(final ActiveContext context) {
while (!scheduler.hasPendingTasks()) {
// Wait until any command enters in the queue
try {
wait();
} catch (final InterruptedException e) {
LOG.log(Level.WARNING, "InterruptedException occurred in SchedulerDri... | java |
private synchronized void retainEvaluator(final ActiveContext context) {
if (scheduler.hasPendingTasks()) {
scheduler.submitTask(context);
} else if (nActiveEval > 1) {
nActiveEval--;
context.close();
} else {
state = State.READY;
waitForCommands(context);
}
} | java |
private synchronized void reallocateEvaluator(final ActiveContext context) {
nActiveEval--;
context.close();
if (scheduler.hasPendingTasks()) {
requestEvaluator(1);
} else if (nActiveEval <= 0) {
state = State.WAIT_EVALUATORS;
requestEvaluator(1);
}
} | java |
Map<String, LocalResource> getResources(
final ResourceLaunchEvent resourceLaunchEvent)
throws IOException {
final Map<String, LocalResource> result = new HashMap<>();
result.putAll(getGlobalResources());
final File localStagingFolder = this.tempFileCreator.createTempDirectory(this.fileNames.g... | java |
private Configuration makeEvaluatorConfiguration(final ResourceLaunchEvent resourceLaunchEvent)
throws IOException {
return Tang.Factory.getTang()
.newConfigurationBuilder(resourceLaunchEvent.getEvaluatorConf())
.build();
} | java |
public synchronized boolean detectRestart() {
if (this.state.hasNotRestarted()) {
resubmissionAttempts = driverRuntimeRestartManager.getResubmissionAttempts();
if (resubmissionAttempts > 0) {
// set the state machine in motion.
this.state = DriverRestartState.BEGAN;
}
}
r... | java |
public synchronized void onRestart(final StartTime startTime,
final List<EventHandler<DriverRestarted>> orderedHandlers) {
if (this.state == DriverRestartState.BEGAN) {
restartEvaluators = driverRuntimeRestartManager.getPreviousEvaluators();
final DriverRestarted res... | java |
public synchronized boolean onRecoverEvaluator(final String evaluatorId) {
if (getStateOfPreviousEvaluator(evaluatorId).isFailedOrNotExpected()) {
final String errMsg = "Evaluator with evaluator ID " + evaluatorId + " not expected to be alive.";
LOG.log(Level.SEVERE, errMsg);
throw new DriverFatal... | java |
private synchronized void onDriverRestartCompleted(final boolean isTimedOut) {
if (this.state != DriverRestartState.COMPLETED) {
final Set<String> outstandingEvaluatorIds = getOutstandingEvaluatorsAndMarkExpired();
driverRuntimeRestartManager.informAboutEvaluatorFailures(outstandingEvaluatorIds);
... | java |
private Set<String> getOutstandingEvaluatorsAndMarkExpired() {
final Set<String> outstanding = new HashSet<>();
for (final String previousEvaluatorId : restartEvaluators.getEvaluatorIds()) {
if (getStateOfPreviousEvaluator(previousEvaluatorId) == EvaluatorRestartState.EXPECTED) {
outstanding.add(p... | java |
private ConstructorDef<?> parseConstructorDef(final AvroConstructorDef def, final boolean isInjectable) {
final List<ConstructorArg> args = new ArrayList<>();
for (final AvroConstructorArg arg : def.getConstructorArgs()) {
args.add(new ConstructorArgImpl(getString(arg.getFullArgClassName()), getString(arg... | java |
private void parseSubHierarchy(final Node parent, final AvroNode n) {
final Node parsed;
if (n.getPackageNode() != null) {
parsed = new PackageNodeImpl(parent, getString(n.getName()), getString(n.getFullName()));
} else if (n.getNamedParameterNode() != null) {
final AvroNamedParameterNode np = n... | java |
@SuppressWarnings({"rawtypes", "unchecked"})
private void wireUpInheritanceRelationships(final AvroNode n) {
if (n.getClassNode() != null) {
final AvroClassNode cn = n.getClassNode();
final ClassNode iface;
try {
iface = (ClassNode) getNode(getString(n.getFullName()));
} catch (fin... | java |
private String[] getStringArray(final List<CharSequence> charSeqList) {
final int length = charSeqList.size();
final String[] stringArray = new String[length];
for (int i = 0; i < length; i++) {
stringArray[i] = getString(charSeqList.get(i));
}
return stringArray;
} | java |
public static LoggingScope getNewLoggingScope(final Level logLevel, final String msg) {
return new LoggingScopeImpl(LOG, logLevel, msg);
} | java |
public LoggingScope getNewLoggingScope(final String msg, final Object[] params) {
return new LoggingScopeImpl(LOG, logLevel, msg, params);
} | java |
public byte[] write(final SpecificRecord message, final long sequence) {
final String classId = getClassId(message.getClass());
try (final ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
LOG.log(Level.FINEST, "Serializing message: {0}", classId);
final IMessageSerializer seria... | java |
public void read(final byte[] messageBytes, final MultiObserver observer) {
try (final InputStream inputStream = new ByteArrayInputStream(messageBytes)) {
// Binary decoder for both the header and the message.
final BinaryDecoder decoder = DecoderFactory.get().binaryDecoder(inputStream, null);
... | java |
private static String getAbsolutePath(final String relativePath) {
final File outputFile = new File(relativePath);
return outputFile.getAbsolutePath();
} | java |
private void addYarnRuntimeDefinition(
final AvroYarnJobSubmissionParameters yarnJobSubmissionParams,
final AvroJobSubmissionParameters jobSubmissionParameters,
final MultiRuntimeDefinitionBuilder builder) {
// create and serialize yarn configuration if defined
final Configuration ... | java |
private void addDummyYarnRuntimeDefinition(
final AvroYarnJobSubmissionParameters yarnJobSubmissionParams,
final AvroJobSubmissionParameters jobSubmissionParameters,
final MultiRuntimeDefinitionBuilder builder) {
// create and serialize yarn configuration if defined
final Configura... | java |
private void addLocalRuntimeDefinition(
final AvroLocalAppSubmissionParameters localAppSubmissionParams,
final AvroJobSubmissionParameters jobSubmissionParameters,
final MultiRuntimeDefinitionBuilder builder) {
// create and serialize local configuration if defined
final Configurat... | java |
String writeDriverConfigurationFile(final String bootstrapJobArgsLocation,
final String bootstrapAppArgsLocation) throws IOException {
final File bootstrapJobArgsFile = new File(bootstrapJobArgsLocation).getCanonicalFile();
final File bootstrapAppArgsFile = new File(... | java |
@SafeVarargs
public final <T> CommandLine processCommandLine(
final String[] args, final Class<? extends Name<?>>... argClasses)
throws IOException, BindException {
for (final Class<? extends Name<?>> c : argClasses) {
registerShortNameOfClass(c);
}
final Options o = getCommandLineOpti... | java |
@SuppressWarnings("checkstyle:avoidhidingcauseexception")
public static ConfigurationBuilder parseToConfigurationBuilder(final String[] args,
final Class<? extends Name<?>>... argClasses)
throws ParseException {
final CommandLine commandLine;
... | java |
public static List<Integer> getUniformCounts(final int elementCount, final int taskCount) {
final int quotient = elementCount / taskCount;
final int remainder = elementCount % taskCount;
final List<Integer> retList = new ArrayList<>();
for (int taskIndex = 0; taskIndex < taskCount; taskIndex++) {
... | java |
@Private
@Override
public void completed(final int taskletId, final TOutput result) {
try {
completedTasklets(result, Collections.singletonList(taskletId));
} catch (final InterruptedException e) {
throw new RuntimeException(e);
}
} | java |
@Private
@Override
public void aggregationCompleted(final List<Integer> taskletIds, final TOutput result) {
try {
completedTasklets(result, taskletIds);
} catch (final InterruptedException e) {
throw new RuntimeException(e);
}
} | java |
@Private
@Override
public void threwException(final int taskletId, final Exception exception) {
try {
failedTasklets(exception, Collections.singletonList(taskletId));
} catch (final InterruptedException e) {
throw new RuntimeException(e);
}
} | java |
@Private
@Override
public void aggregationThrewException(final List<Integer> taskletIds, final Exception exception) {
try {
failedTasklets(exception, taskletIds);
} catch (final InterruptedException e) {
throw new RuntimeException(e);
}
} | java |
private void completedTasklets(final TOutput output, final List<Integer> taskletIds)
throws InterruptedException {
final List<TInput> inputs = getInputs(taskletIds);
final AggregateResult result = new AggregateResult(output, inputs);
if (callbackHandler != null) {
executor.execute(new Runnable(... | java |
private void failedTasklets(final Exception exception, final List<Integer> taskletIds)
throws InterruptedException {
final List<TInput> inputs = getInputs(taskletIds);
final AggregateResult failure = new AggregateResult(exception, inputs);
if (callbackHandler != null) {
executor.execute(new Ru... | java |
private List<TInput> getInputs(final List<Integer> taskletIds) {
final List<TInput> inputList = new ArrayList<>(taskletIds.size());
for(final int taskletId : taskletIds) {
inputList.add(taskletIdInputMap.get(taskletId));
}
return inputList;
} | java |
@Override
public void onNext(final ResourceLaunchEvent resourceLaunchEvent) {
LOG.log(Level.FINEST, "Got ResourceLaunchEvent in AzureBatchResourceLaunchHandler");
this.azureBatchResourceManager.onResourceLaunched(resourceLaunchEvent);
} | java |
public synchronized void fireEvaluatorAllocatedEvent() {
if (this.stateManager.isAllocated() && this.allocationNotFired) {
final AllocatedEvaluator allocatedEvaluator =
new AllocatedEvaluatorImpl(this,
this.remoteManager.getMyIdentifier(),
this.configurationSerializer,
... | java |
public void onEvaluatorException(final EvaluatorException exception) {
synchronized (this.evaluatorDescriptor) {
if (this.stateManager.isCompleted()) {
LOG.log(Level.FINE,
"Ignoring an exception received for Evaluator {0} which is already in state {1}.",
new Object[] {this.get... | java |
public void onEvaluatorHeartbeatMessage(
final RemoteMessage<EvaluatorRuntimeProtocol.EvaluatorHeartbeatProto> evaluatorHeartbeatProtoRemoteMessage) {
final EvaluatorRuntimeProtocol.EvaluatorHeartbeatProto evaluatorHeartbeatProto =
evaluatorHeartbeatProtoRemoteMessage.getMessage();
LOG.log(Level... | java |
private synchronized void onEvaluatorStatusMessage(final EvaluatorStatusPOJO message) {
switch (message.getState()) {
case DONE:
this.onEvaluatorDone(message);
break;
case FAILED:
this.onEvaluatorFailed(message);
break;
case KILLED:
this.onEvaluatorKilled(message);
b... | java |
private synchronized void onEvaluatorDone(final EvaluatorStatusPOJO message) {
assert message.getState() == State.DONE;
LOG.log(Level.FINEST, "Evaluator {0} done.", getId());
// Send an ACK to the Evaluator.
sendEvaluatorControlMessage(
EvaluatorRuntimeProtocol.EvaluatorControlProto.newBuilde... | java |
private synchronized void onEvaluatorFailed(final EvaluatorStatusPOJO evaluatorStatus) {
assert evaluatorStatus.getState() == State.FAILED;
final EvaluatorException evaluatorException;
if (evaluatorStatus.hasError()) {
final Optional<Throwable> exception =
this.exceptionCodec.fromBytes(e... | java |
private synchronized void onEvaluatorKilled(final EvaluatorStatusPOJO message) {
assert message.getState() == State.KILLED;
assert this.stateManager.isClosing();
LOG.log(Level.WARNING, "Evaluator {0} killed completely.", getId());
this.stateManager.setKilled();
} | java |
public void sendContextControlMessage(final EvaluatorRuntimeProtocol.ContextControlProto contextControlProto) {
synchronized (this.evaluatorDescriptor) {
LOG.log(Level.FINEST, "Context control message to {0}", this.evaluatorId);
this.contextControlHandler.send(contextControlProto);
}
} | java |
private void onTaskStatusMessage(final TaskStatusPOJO taskStatus) {
if (!(this.task.isPresent() && this.task.get().getId().equals(taskStatus.getTaskId()))) {
final State state = taskStatus.getState();
if (state.isRestartable() ||
this.driverRestartManager.getEvaluatorRestartState(this.evalua... | java |
@Override
public boolean isReady(final long time) {
while (true) {
final long thisTs = this.current.get();
if (thisTs >= time || this.current.compareAndSet(thisTs, time)) {
return true;
}
}
} | java |
@Override
public byte[] encode(final T writable) {
try (final ByteArrayOutputStream bos = new ByteArrayOutputStream();
final DataOutputStream dos = new DataOutputStream(bos)) {
writable.write(dos);
return bos.toByteArray();
} catch (final IOException ex) {
LOG.log(Level.SEVERE, "Can... | java |
@Override
public T decode(final byte[] buffer) {
try (final ByteArrayInputStream bis = new ByteArrayInputStream(buffer);
final DataInputStream dis = new DataInputStream(bis)) {
final T writable = this.writableClass.newInstance();
writable.readFields(dis);
return writable;
} catch (f... | java |
public void submitJob(final String applicationId, final String storageContainerSAS, final URI jobJarUri,
final String command) throws IOException {
final ResourceFile jarResourceFile = new ResourceFile()
.withBlobSource(jobJarUri.toString())
.withFilePath(AzureBatchFileNames.... | java |
public void submitTask(final String jobId, final String taskId, final URI jobJarUri,
final URI confUri, final String command)
throws IOException {
final List<ResourceFile> resources = new ArrayList<>();
final ResourceFile jarSourceFile = new ResourceFile()
.withBlobSourc... | java |
public List<CloudTask> getTaskStatusForJob(final String jobId) {
List<CloudTask> tasks = null;
try {
tasks = client.taskOperations().listTasks(jobId);
LOG.log(Level.INFO, "Task status for job: {0} returned {1} tasks", new Object[]{jobId, tasks.size()});
} catch (IOException | BatchErrorException... | java |
@Override
public byte[] encode(final NamingLookupRequest obj) {
final List<CharSequence> ids = new ArrayList<>();
for (final Identifier id : obj.getIdentifiers()) {
ids.add(id.toString());
}
return AvroUtils.toBytes(AvroNamingLookupRequest.newBuilder().setIds(ids).build(), AvroNamingLookupReques... | java |
@Override
public NamingLookupRequest decode(final byte[] buf) {
final AvroNamingLookupRequest req = AvroUtils.fromBytes(buf, AvroNamingLookupRequest.class);
final List<Identifier> ids = new ArrayList<>(req.getIds().size());
for (final CharSequence s : req.getIds()) {
ids.add(factory.getNewInstance(... | java |
public static void main(final String[] args) throws BindException, InjectionException {
final Configuration runtimeConf = getRuntimeConfiguration();
final Configuration driverConf = getDriverConfiguration();
final LauncherStatus status = DriverLauncher
.getLauncher(runtimeConf)
.run(driverC... | java |
private void setState(final EvaluatorState toState) {
while (true) {
final EvaluatorState fromState = this.state.get();
if (fromState == toState) {
break;
}
if (!fromState.isLegalTransition(toState)) {
LOG.log(Level.WARNING, "Illegal state transition: {0} -> {1}", new Objec... | java |
public static byte[] encode(final TaskNode root) {
try (final ByteArrayOutputStream bstream = new ByteArrayOutputStream();
final DataOutputStream dstream = new DataOutputStream(bstream)) {
encodeHelper(dstream, root);
return bstream.toByteArray();
} catch (final IOException e) {
thro... | java |
public static Pair<TopologySimpleNode, List<Identifier>> decode(
final byte[] data,
final IdentifierFactory ifac) {
try (final DataInputStream dstream = new DataInputStream(new ByteArrayInputStream(data))) {
final List<Identifier> activeSlaveTasks = new LinkedList<>();
final TopologySimpleN... | java |
public synchronized void submitTask(final ActiveContext context) {
final TaskEntity task = taskQueue.poll();
final Integer taskId = task.getId();
final String command = task.getCommand();
final Configuration taskConf = TaskConfiguration.CONF
.set(TaskConfiguration.TASK, ShellTask.class)
... | java |
public synchronized int cancelTask(final int taskId) throws UnsuccessfulException, NotFoundException {
if (getTask(taskId, runningTasks) != null) {
throw new UnsuccessfulException("The task " + taskId + " is running");
} else if (getTask(taskId, finishedTasks) != null) {
throw new UnsuccessfulExcept... | java |
public synchronized int clear() {
final int count = taskQueue.size();
for (final TaskEntity task : taskQueue) {
canceledTasks.add(task);
}
taskQueue.clear();
return count;
} | java |
public synchronized Map<String, List<Integer>> getList() {
final Map<String, List<Integer>> tasks = new LinkedHashMap<>();
tasks.put("Running", getTaskIdList(runningTasks));
tasks.put("Waiting", getTaskIdList(taskQueue));
tasks.put("Finished", getTaskIdList(finishedTasks));
tasks.put("Canceled", ge... | java |
public synchronized String getTaskStatus(final int taskId) throws NotFoundException {
final TaskEntity running = getTask(taskId, runningTasks);
if (running != null) {
return "Running : " + running.toString();
}
final TaskEntity waiting = getTask(taskId, taskQueue);
if (waiting != null) {
... | java |
public synchronized void setFinished(final int taskId) {
final TaskEntity task = getTask(taskId, runningTasks);
runningTasks.remove(task);
finishedTasks.add(task);
} | java |
private static TaskEntity getTask(final int taskId, final Collection<TaskEntity> tasks) {
for (final TaskEntity task : tasks) {
if (taskId == task.getId()) {
return task;
}
}
return null;
} | java |
public static synchronized boolean assertSingleton(final String scopeId, final Class clazz) {
ALL_CLASSES.add(clazz);
return SINGLETONS_SCOPED.add(new Tuple<>(scopeId, clazz)) && !SINGLETONS_GLOBAL.contains(clazz);
} | java |
private Configuration createDriverConfiguration(final Configuration driverConfiguration) {
final ConfigurationBuilder configurationBuilder = Tang.Factory.getTang()
.newConfigurationBuilder(driverConfiguration);
for (final ConfigurationProvider configurationProvider : this.configurationProviders) {
... | java |
@Override
public AvroEvaluatorsInfo toAvro(
final List<String> ids, final Map<String, EvaluatorDescriptor> evaluators) {
final List<AvroEvaluatorInfo> evaluatorsInfo = new ArrayList<>();
for (final String id : ids) {
final EvaluatorDescriptor evaluatorDescriptor = evaluators.get(id);
Stri... | java |
public synchronized V loadAndGet() throws ExecutionException {
try {
value = Optional.ofNullable(valueFetcher.call());
} catch (final Exception e) {
throw new ExecutionException(e);
} finally {
writeTime = Optional.of(currentTime.now());
this.notifyAll();
}
if (!value.isPrese... | java |
private List<List<Double>> deepCopy(final List<List<Double>> original) {
final List<List<Double>> result = new ArrayList<>(original.size());
for (final List<Double> originalRow : original) {
final List<Double> row = new ArrayList<>(originalRow.size());
for (final double element : originalRow) {
... | java |
@Override
public void onNext(final String alarmId) {
LOG.log(Level.INFO, "Alarm {0} triggered", alarmId);
final ClientAlarm clientAlarm = this.alarmMap.remove(alarmId);
if (clientAlarm != null) {
clientAlarm.run();
} else {
LOG.log(Level.SEVERE, "Unknown alarm id {0}", alarmId);
}
} | java |
public void deserialize(final BinaryDecoder decoder, final MultiObserver observer, final long sequence)
throws IOException, IllegalAccessException, InvocationTargetException {
final TMessage message = messageReader.read(null, decoder);
if (message != null) {
observer.onNext(sequence, message);
} ... | java |
synchronized void close() {
if (this.remoteManager.isPresent()) {
try {
this.remoteManager.get().close();
} catch (final Exception e) {
LOG.log(Level.WARNING, "Exception while shutting down the RemoteManager.", e);
}
}
} | java |
@Override
public synchronized void onNext(final ClientRuntimeProtocol.JobControlProto jobControlProto) {
if (jobControlProto.hasSignal()) {
if (jobControlProto.getSignal() == ClientRuntimeProtocol.Signal.SIG_TERMINATE) {
try {
if (jobControlProto.hasMessage()) {
getClientCloseW... | java |
@Override
public void onNext(final T event) {
if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "remoteid: {0}\n{1}", new Object[]{remoteId.getSocketAddress(), event.toString()});
}
handler.onNext(new RemoteEvent<T>(myId.getSocketAddress(), remoteId.getSocketAddress(),
seqGen.getNextSeq(... | java |
@Override
public byte[] encode(final NamingRegisterRequest obj) {
final AvroNamingRegisterRequest result = AvroNamingRegisterRequest.newBuilder()
.setId(obj.getNameAssignment().getIdentifier().toString())
.setHost(obj.getNameAssignment().getAddress().getHostName())
.setPort(obj.getNameAssi... | java |
@Override
public NamingRegisterRequest decode(final byte[] buf) {
final AvroNamingRegisterRequest avroNamingRegisterRequest =
AvroUtils.fromBytes(buf, AvroNamingRegisterRequest.class);
return new NamingRegisterRequest(
new NameAssignmentTuple(factory.getNewInstance(avroNamingRegisterRequest.ge... | java |
@Override
public void addHttpHandler(final HttpHandler httpHandler) {
LOG.log(Level.INFO, "addHttpHandler: {0}", httpHandler.getUriSpecification());
jettyHandler.addHandler(httpHandler);
} | java |
@Override
public byte[] encode(final NetworkConnectionServiceMessage obj) {
final Codec codec = connFactoryMap.get(obj.getConnectionFactoryId()).getCodec();
Boolean isStreamingCodec = isStreamingCodecMap.get(codec);
if (isStreamingCodec == null) {
isStreamingCodec = codec instanceof StreamingCodec;
... | java |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.