_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q22000
SchedulerUtils.createOrCleanDirectory
train
public static boolean createOrCleanDirectory(String directory) { // if the directory does not exist, create it. if (!FileUtils.isDirectoryExists(directory)) { LOG.fine("The directory does not exist; creating it."); if (!FileUtils.createDirectory(directory)) { LOG.severe("Failed to create dir...
java
{ "resource": "" }
q22001
SchedulerUtils.curlAndExtractPackage
train
public static boolean curlAndExtractPackage( String workingDirectory, String packageURI, String packageDestination, boolean isDeletePackage, boolean isVerbose) { // curl the package to the working directory and extract it LOG.log(Level.FINE, "Fetching package {0}", packageURI); ...
java
{ "resource": "" }
q22002
SchedulerUtils.persistUpdatedPackingPlan
train
public static void persistUpdatedPackingPlan(String topologyName, PackingPlan updatedPackingPlan, SchedulerStateManagerAdaptor stateManager) { LOG.log(Level.INFO, "Updating scheduled-resource in packing plan: {0}", topolog...
java
{ "resource": "" }
q22003
PackingPlanBuilder.build
train
public PackingPlan build() { assertResourceSettings(); Set<PackingPlan.ContainerPlan> containerPlans = buildContainerPlans(this.containers); return new PackingPlan(topologyId, containerPlans); }
java
{ "resource": "" }
q22004
PackingPlanBuilder.buildContainerPlans
train
private static Set<PackingPlan.ContainerPlan> buildContainerPlans( Map<Integer, Container> containerInstances) { Set<PackingPlan.ContainerPlan> containerPlans = new LinkedHashSet<>(); for (Integer containerId : containerInstances.keySet()) { Container container = containerInstances.get(containerId)...
java
{ "resource": "" }
q22005
PackingPlanBuilder.getContainers
train
@VisibleForTesting static Map<Integer, Container> getContainers( PackingPlan currentPackingPlan, Resource maxContainerResource, Resource padding, Map<String, TreeSet<Integer>> componentIndexes, TreeSet<Integer> taskIds) { Map<Integer, Container> containers = new HashMap<>(); Resource capacity = m...
java
{ "resource": "" }
q22006
PackingPlanBuilder.addToContainer
train
private static void addToContainer(Container container, PackingPlan.InstancePlan instancePlan, Map<String, TreeSet<Integer>> componentIndexes, Set<Integer> taskIds) { container.add(instancePlan); Strin...
java
{ "resource": "" }
q22007
StreamletUtils.randomFromList
train
public static <T> T randomFromList(List<T> ls) { return ls.get(new Random().nextInt(ls.size())); }
java
{ "resource": "" }
q22008
StreamletUtils.getParallelism
train
public static int getParallelism(String[] args, int defaultParallelism) { return (args.length > 1) ? Integer.parseInt(args[1]) : defaultParallelism; }
java
{ "resource": "" }
q22009
StreamletUtils.intListAsString
train
public static String intListAsString(List<Integer> ls) { return String.join(", ", ls.stream().map(i -> i.toString()).collect(Collectors.toList())); }
java
{ "resource": "" }
q22010
HeronClient.sendRequest
train
public void sendRequest(Message request, Object context, Message.Builder responseBuilder, Duration timeout) { // Pack it as a no-timeout request and send it! final REQID rid = REQID.generate(); contextMap.put(rid, context); responseMessageMap.put(rid, responseBuilder); // ...
java
{ "resource": "" }
q22011
HeronClient.sendRequest
train
public void sendRequest(Message request, Message.Builder responseBuilder) { sendRequest(request, null, responseBuilder, Duration.ZERO); }
java
{ "resource": "" }
q22012
HeronClient.handleTimeout
train
protected void handleTimeout(REQID rid) { if (contextMap.containsKey(rid)) { Object ctx = contextMap.get(rid); contextMap.remove(rid); responseMessageMap.remove(rid); onResponse(StatusCode.TIMEOUT_ERROR, ctx, null); } else { // Since we dont do cancel timer, this is because we alre...
java
{ "resource": "" }
q22013
MesosScheduler.startSchedulerDriver
train
protected void startSchedulerDriver() { // start the driver non-blocking, // since we need to set heron state after the scheduler driver is started. // Heron will block the main thread eventually driver.start(); // Staging the Mesos Framework LOG.info("Waiting for Mesos Framework get registered...
java
{ "resource": "" }
q22014
MesosScheduler.joinSchedulerDriver
train
protected void joinSchedulerDriver(long timeout, TimeUnit unit) { // ExecutorService used to monitor whether close() completes in time ExecutorService service = Executors.newFixedThreadPool(1); final CountDownLatch closeLatch = new CountDownLatch(1); Runnable driverJoin = new Runnable() { @Overrid...
java
{ "resource": "" }
q22015
MesosScheduler.getBaseContainer
train
protected BaseContainer getBaseContainer(Integer containerIndex, PackingPlan packing) { BaseContainer container = new BaseContainer(); container.name = TaskUtils.getTaskNameForContainerIndex(containerIndex); container.runAsUser = Context.role(config); container.description = String.format("Container %...
java
{ "resource": "" }
q22016
LaunchableTask.constructMesosTaskInfo
train
public Protos.TaskInfo constructMesosTaskInfo(Config heronConfig, Config heronRuntime) { //String taskIdStr, BaseContainer task, Offer offer String taskIdStr = this.taskId; Protos.TaskID mesosTaskID = Protos.TaskID.newBuilder().setValue(taskIdStr).build(); Protos.TaskInfo.Builder taskInfo = Protos.Task...
java
{ "resource": "" }
q22017
MetricsCollector.gatherOneMetric
train
@SuppressWarnings("unchecked") private void gatherOneMetric( String metricName, Metrics.MetricPublisherPublishMessage.Builder builder) { Object metricValue = metrics.get(metricName).getValueAndReset(); // Decide how to handle the metric based on type if (metricValue == null) { return; ...
java
{ "resource": "" }
q22018
MetricsCacheQueryUtils.fromProtobuf
train
public static MetricRequest fromProtobuf(TopologyMaster.MetricRequest request) { String componentName = request.getComponentName(); Map<String, Set<String>> componentNameInstanceId = new HashMap<>(); if (request.getInstanceIdCount() == 0) { // empty list means all instances // 'null' means all ...
java
{ "resource": "" }
q22019
MetricsCacheQueryUtils.toProtobuf
train
public static TopologyMaster.MetricResponse toProtobuf(MetricResponse response, MetricRequest request) { TopologyMaster.MetricResponse.Builder builder = TopologyMaster.MetricResponse.newBuilder(); builder.setInterval((request.getEndTime() - reques...
java
{ "resource": "" }
q22020
MetricsCacheQueryUtils.fromProtobuf
train
public static ExceptionRequest fromProtobuf(TopologyMaster.ExceptionLogRequest request) { String componentName = request.getComponentName(); Map<String, Set<String>> componentNameInstanceId = new HashMap<>(); Set<String> instances = null; if (request.getInstancesCount() > 0) { instances = new Ha...
java
{ "resource": "" }
q22021
MetricsCacheQueryUtils.toProtobuf
train
public static TopologyMaster.ExceptionLogResponse toProtobuf(ExceptionResponse response) { TopologyMaster.ExceptionLogResponse.Builder builder = TopologyMaster.ExceptionLogResponse.newBuilder(); // default OK if we have response to build already builder.setStatus(Common.Status.newBuilder().setStatus...
java
{ "resource": "" }
q22022
TopologyManager.getComponentToTaskIds
train
public Map<String, List<Integer>> getComponentToTaskIds() { if (this.componentToTaskIds == null) { this.componentToTaskIds = new HashMap<>(); // Iterate over all instances and insert necessary info into the map for (PhysicalPlans.Instance instance : this.getPhysicalPlan().getInstancesList()) { ...
java
{ "resource": "" }
q22023
TopologyManager.extractTopologyTimeout
train
public Duration extractTopologyTimeout() { for (TopologyAPI.Config.KeyValue keyValue : this.getTopology().getTopologyConfig().getKvsList()) { if (keyValue.getKey().equals("topology.message.timeout.secs")) { return TypeUtils.getDuration(keyValue.getValue(), ChronoUnit.SECONDS); } } ...
java
{ "resource": "" }
q22024
TopologyManager.getStreamConsumers
train
public HashMap<TopologyAPI.StreamId, List<Grouping>> getStreamConsumers() { if (this.streamConsumers == null) { this.streamConsumers = new HashMap<>(); // First get a map of (TopologyAPI.StreamId -> TopologyAPI.StreamSchema) Map<TopologyAPI.StreamId, TopologyAPI.StreamSchema> streamToSchema = ...
java
{ "resource": "" }
q22025
HeronServer.stop
train
public void stop() { if (acceptChannel == null || !acceptChannel.isOpen()) { LOG.info("Fail to stop server; not yet open."); return; } // Clear all connected socket and related stuff for (Map.Entry<SocketChannel, SocketChannelHelper> connections : activeConnections.entrySet()) { Socket...
java
{ "resource": "" }
q22026
GlobalMetrics.incr
train
public static void incr(String counterName) { org.apache.heron.api.metric.GlobalMetrics.incr(counterName); }
java
{ "resource": "" }
q22027
RuntimeManagerRunner.activateTopologyHandler
train
private void activateTopologyHandler(String topologyName) throws TMasterException { assert !potentialStaleExecutionData; NetworkUtils.TunnelConfig tunnelConfig = NetworkUtils.TunnelConfig.build(config, NetworkUtils.HeronSystem.SCHEDULER); TMasterUtils.transitionTopologyState(topologyName, TM...
java
{ "resource": "" }
q22028
RuntimeManagerRunner.cleanState
train
protected void cleanState( String topologyName, SchedulerStateManagerAdaptor statemgr) throws TopologyRuntimeManagementException { LOG.fine("Cleaning up topology state"); Boolean result; result = statemgr.deleteTMasterLocation(topologyName); if (result == null || !result) { throw new...
java
{ "resource": "" }
q22029
FirstFitDecreasingPacking.pack
train
@Override public PackingPlan pack() { PackingPlanBuilder planBuilder = newPackingPlanBuilder(null); // Get the instances using FFD allocation try { planBuilder = getFFDAllocation(planBuilder); } catch (ConstraintViolationException e) { throw new PackingException("Could not allocate all in...
java
{ "resource": "" }
q22030
FirstFitDecreasingPacking.assignInstancesToContainers
train
private void assignInstancesToContainers(PackingPlanBuilder planBuilder, Map<String, Integer> parallelismMap) throws ConstraintViolationException { List<ResourceRequirement> resourceRequirements = getSortedInstances(parallelismMap.keySet()); for (Resource...
java
{ "resource": "" }
q22031
FirstFitDecreasingPacking.placeFFDInstance
train
private void placeFFDInstance(PackingPlanBuilder planBuilder, String componentName) throws ConstraintViolationException { if (this.numContainers == 0) { planBuilder.updateNumContainers(++numContainers); } try { planBuilder.addInstance(new ContainerIdScorer(), componentName); } catch (...
java
{ "resource": "" }
q22032
TupleCache.getCache
train
public Map<Integer, List<HeronTuples.HeronTupleSet>> getCache() { Map<Integer, List<HeronTuples.HeronTupleSet>> res = new HashMap<>(); for (Map.Entry<Integer, TupleList> entry : cache.entrySet()) { res.put(entry.getKey(), entry.getValue().getTuplesList()); } return res; }
java
{ "resource": "" }
q22033
NetworkUtils.readHttpRequestBody
train
public static byte[] readHttpRequestBody(HttpExchange exchange) { // Get the length of request body int contentLength = Integer.parseInt(exchange.getRequestHeaders().getFirst(CONTENT_LENGTH)); if (contentLength <= 0) { LOG.log(Level.SEVERE, "Failed to read content length http request body: " + conten...
java
{ "resource": "" }
q22034
NetworkUtils.sendHttpResponse
train
public static boolean sendHttpResponse( boolean isSuccess, HttpExchange exchange, byte[] response) { int returnCode = isSuccess ? HttpURLConnection.HTTP_OK : HttpURLConnection.HTTP_UNAVAILABLE; try { exchange.sendResponseHeaders(returnCode, response.length); } catch (IOException e) {...
java
{ "resource": "" }
q22035
NetworkUtils.sendHttpPostRequest
train
public static boolean sendHttpPostRequest(HttpURLConnection connection, String contentType, byte[] data) { try { connection.setRequestMethod("POST"); } catch (ProtocolException e) { LOG.log(Level.SEVERE, "Failed ...
java
{ "resource": "" }
q22036
NetworkUtils.readHttpResponse
train
public static byte[] readHttpResponse(HttpURLConnection connection) { byte[] res; try { if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) { LOG.log(Level.WARNING, "Http Response not OK: " + connection.getResponseCode()); } } catch (IOException e) { LOG.log(Level.SEVER...
java
{ "resource": "" }
q22037
TMasterUtils.sendToTMaster
train
@VisibleForTesting public static void sendToTMaster(String command, String topologyName, SchedulerStateManagerAdaptor stateManager, NetworkUtils.TunnelConfig tunnelConfig) throws TMasterException { final...
java
{ "resource": "" }
q22038
TMasterUtils.getRuntimeTopologyState
train
private static TopologyAPI.TopologyState getRuntimeTopologyState( String topologyName, SchedulerStateManagerAdaptor statemgr) throws TMasterException { PhysicalPlans.PhysicalPlan plan = statemgr.getPhysicalPlan(topologyName); if (plan == null) { throw new TMasterException(String.format( ...
java
{ "resource": "" }
q22039
RoundRobinPacking.getRoundRobinAllocation
train
private Map<Integer, List<InstanceId>> getRoundRobinAllocation( int numContainer, Map<String, Integer> parallelismMap) { Map<Integer, List<InstanceId>> allocation = new HashMap<>(); int totalInstance = TopologyUtils.getTotalInstance(parallelismMap); if (numContainer < 1) { throw new RuntimeExcep...
java
{ "resource": "" }
q22040
RoundRobinPacking.validatePackingPlan
train
private void validatePackingPlan(PackingPlan plan) throws PackingException { for (PackingPlan.ContainerPlan containerPlan : plan.getContainers()) { for (PackingPlan.InstancePlan instancePlan : containerPlan.getInstances()) { // Safe check if (instancePlan.getResource().getRam().lessThan(MIN_RA...
java
{ "resource": "" }
q22041
Resource.subtractAbsolute
train
public Resource subtractAbsolute(Resource other) { double cpuDifference = this.getCpu() - other.getCpu(); double extraCpu = Math.max(0, cpuDifference); ByteAmount ramDifference = this.getRam().minus(other.getRam()); ByteAmount extraRam = ByteAmount.ZERO.max(ramDifference); ByteAmount diskDifference ...
java
{ "resource": "" }
q22042
Resource.plus
train
public Resource plus(Resource other) { double totalCpu = this.getCpu() + other.getCpu(); ByteAmount totalRam = this.getRam().plus(other.getRam()); ByteAmount totalDisk = this.getDisk().plus(other.getDisk()); return new Resource(totalCpu, totalRam, totalDisk); }
java
{ "resource": "" }
q22043
Resource.divideBy
train
public double divideBy(Resource other) throws RuntimeException { if (other.getCpu() == 0 || other.getRam().isZero() || other.getDisk().isZero()) { throw new RuntimeException("Division by 0."); } else { double cpuFactor = Math.ceil(this.getCpu() / other.getCpu()); double ramFactor = Math.ceil((...
java
{ "resource": "" }
q22044
StreamletUtils.checkNotBlank
train
public static String checkNotBlank(String text, String errorMessage) { if (StringUtils.isBlank(text)) { throw new IllegalArgumentException(errorMessage); } else { return text; } }
java
{ "resource": "" }
q22045
ConfigUtils.translateConfig
train
@SuppressWarnings({"rawtypes", "unchecked"}) public static Config translateConfig(Map stormConfig) { Config heronConfig; if (stormConfig != null) { heronConfig = new Config((Map<String, Object>) stormConfig); } else { heronConfig = new Config(); } // Look at serialization stuff first ...
java
{ "resource": "" }
q22046
ConfigUtils.translateComponentConfig
train
@SuppressWarnings({"rawtypes", "unchecked"}) public static Config translateComponentConfig(Map stormConfig) { Config heronConfig; if (stormConfig != null) { heronConfig = new Config((Map<String, Object>) stormConfig); } else { heronConfig = new Config(); } doStormTranslation(heronConf...
java
{ "resource": "" }
q22047
ConfigUtils.doTopologyLevelTranslation
train
private static void doTopologyLevelTranslation(Config heronConfig) { if (heronConfig.containsKey(org.apache.storm.Config.TOPOLOGY_ACKER_EXECUTORS)) { Integer nAckers = Utils.getInt(heronConfig.get(org.apache.storm.Config.TOPOLOGY_ACKER_EXECUTORS)); if (nAckers > 0) { org.apache.heron.a...
java
{ "resource": "" }
q22048
MetricsManagerClient.sendRegisterRequest
train
private void sendRegisterRequest() { Metrics.MetricPublisher publisher = Metrics.MetricPublisher.newBuilder(). setHostname(hostname). setPort(instance.getInfo().getTaskId()). setComponentName(instance.getInfo().getComponentName()). setInstanceId(instance.getInstanceId()). set...
java
{ "resource": "" }
q22049
HttpJsonClient.get
train
public JsonNode get(Integer expectedResponseCode) throws IOException { HttpURLConnection conn = getUrlConnection(); byte[] responseData; try { if (!NetworkUtils.sendHttpGetRequest(conn)) { throw new IOException("Failed to send get request to " + endpointURI); } // Check the respon...
java
{ "resource": "" }
q22050
HttpJsonClient.delete
train
public void delete(Integer expectedResponseCode) throws IOException { HttpURLConnection conn = getUrlConnection(); try { if (!NetworkUtils.sendHttpDeleteRequest(conn)) { throw new IOException("Failed to send delete request to " + endpointURI); } // Check the response code if (!N...
java
{ "resource": "" }
q22051
HttpJsonClient.post
train
public void post(String jsonBody, Integer expectedResponseCode) throws IOException { HttpURLConnection conn = getUrlConnection(); try { // send post request with json body for the topology if (!NetworkUtils.sendHttpPostRequest(conn, NetworkUtils.JSON_TYPE, jsonBody.getBytes())) { throw new ...
java
{ "resource": "" }
q22052
SocketChannelHelper.read
train
public List<IncomingPacket> read() { // We record the start time to avoid spending too much time on readings long startOfCycle = System.nanoTime(); long bytesRead = 0; long nPacketsRead = 0; List<IncomingPacket> ret = new ArrayList<IncomingPacket>(); // We would stop reading when: // 1. W...
java
{ "resource": "" }
q22053
SocketChannelHelper.write
train
public void write() { // We record the start time to avoid spending too much time on writings long startOfCycle = System.nanoTime(); long bytesWritten = 0; long nPacketsWritten = 0; while ((System.nanoTime() - startOfCycle - writeBatchTime.toNanos()) < 0 && (bytesWritten < writeBatchSize.a...
java
{ "resource": "" }
q22054
TokenSub.combinePaths
train
private static String combinePaths(List<String> paths) { File file = new File(paths.get(0)); for (int i = 1; i < paths.size(); i++) { file = new File(file, paths.get(i)); } return file.getPath(); }
java
{ "resource": "" }
q22055
InstanceExecutor.handleControlSignal
train
protected void handleControlSignal() { if (toActivate) { if (!isInstanceStarted) { startInstance(); } instance.activate(); LOG.info("Activated instance: " + physicalPlanHelper.getMyInstanceId()); // Reset the flag value toActivate = false; } if (toDeactivate) {...
java
{ "resource": "" }
q22056
Config.setEnableAcking
train
@Deprecated public static void setEnableAcking(Map<String, Object> conf, boolean acking) { if (acking) { setTopologyReliabilityMode(conf, Config.TopologyReliabilityMode.ATLEAST_ONCE); } else { setTopologyReliabilityMode(conf, Config.TopologyReliabilityMode.ATMOST_ONCE); } }
java
{ "resource": "" }
q22057
Config.registerTopologyTimerEvents
train
@SuppressWarnings("unchecked") public static void registerTopologyTimerEvents(Map<String, Object> conf, String name, Duration interval, Runnable task) { if (interval.isZero() || interval.isNegative()) { throw n...
java
{ "resource": "" }
q22058
Runner.run
train
public void run(String name, Config config, Builder builder) { BuilderImpl bldr = (BuilderImpl) builder; TopologyBuilder topologyBuilder = bldr.build(); try { HeronSubmitter.submitTopology(name, config.getHeronConfig(), topologyBuilder.createTopology()); } catch...
java
{ "resource": "" }
q22059
DLInputStream.nextLogRecord
train
private LogRecordWithInputStream nextLogRecord() throws IOException { try { return nextLogRecord(reader); } catch (EndOfStreamException e) { eos = true; LOG.info(()->"end of stream is reached"); return null; } }
java
{ "resource": "" }
q22060
LaunchRunner.trimTopology
train
public TopologyAPI.Topology trimTopology(TopologyAPI.Topology topology) { // create a copy of the topology physical plan TopologyAPI.Topology.Builder builder = TopologyAPI.Topology.newBuilder().mergeFrom(topology); // clear the state of user spout java objects - which can be potentially huge for (Topo...
java
{ "resource": "" }
q22061
LaunchRunner.call
train
public void call() throws LauncherException, PackingException, SubmitDryRunResponse { SchedulerStateManagerAdaptor statemgr = Runtime.schedulerStateManagerAdaptor(runtime); TopologyAPI.Topology topology = Runtime.topology(runtime); String topologyName = Context.topologyName(config); PackingPlan packedP...
java
{ "resource": "" }
q22062
LocalScheduler.startExecutorProcess
train
@VisibleForTesting protected Process startExecutorProcess(int container, Set<PackingPlan.InstancePlan> instances) { return ShellUtils.runASyncProcess( getExecutorCommand(container, instances), new File(LocalContext.workingDirectory(config)), Integer.toString(container)); }
java
{ "resource": "" }
q22063
LocalScheduler.startExecutor
train
@VisibleForTesting protected void startExecutor(final int container, Set<PackingPlan.InstancePlan> instances) { LOG.info("Starting a new executor for container: " + container); // create a process with the executor command and topology working directory final Process containerExecutor = startExecutorProc...
java
{ "resource": "" }
q22064
LocalScheduler.startExecutorMonitor
train
@VisibleForTesting protected void startExecutorMonitor(final int container, final Process containerExecutor, Set<PackingPlan.InstancePlan> instances) { // add the container for monitoring Runnable r = new Runnable() { @Override ...
java
{ "resource": "" }
q22065
LocalScheduler.onSchedule
train
@Override public boolean onSchedule(PackingPlan packing) { LOG.info("Starting to deploy topology: " + LocalContext.topologyName(config)); synchronized (processToContainer) { LOG.info("Starting executor for TMaster"); startExecutor(0, null); // for each container, run its own executor ...
java
{ "resource": "" }
q22066
LocalScheduler.onKill
train
@Override public boolean onKill(Scheduler.KillTopologyRequest request) { // get the topology name String topologyName = LocalContext.topologyName(config); LOG.info("Command to kill topology: " + topologyName); // set the flag that the topology being killed isTopologyKilled = true; synchroni...
java
{ "resource": "" }
q22067
LocalScheduler.onRestart
train
@Override public boolean onRestart(Scheduler.RestartTopologyRequest request) { // Containers would be restarted automatically once we destroy it int containerId = request.getContainerIndex(); List<Process> processesToRestart = new LinkedList<>(); if (containerId == -1) { LOG.info("Command to r...
java
{ "resource": "" }
q22068
AuroraHeronShellController.restart
train
@Override public boolean restart(Integer containerId) { // there is no backpressure for container 0, delegate to aurora client if (containerId == null || containerId == 0) { return cliController.restart(containerId); } if (stateMgrAdaptor == null) { LOG.warning("SchedulerStateManagerAdapt...
java
{ "resource": "" }
q22069
TaskResources.canSatisfy
train
public boolean canSatisfy(TaskResources needed) { return this.ports >= needed.ports && (this.cpu >= needed.cpu) && (this.mem >= needed.mem) && (this.disk >= needed.disk); }
java
{ "resource": "" }
q22070
TaskResources.apply
train
public static TaskResources apply(Protos.Offer offer, String role) { double cpu = 0; double mem = 0; double disk = 0; List<Range> portsResource = new ArrayList<>(); for (Protos.Resource r : offer.getResourcesList()) { if (!r.hasRole() || r.getRole().equals("*") || r.getRole().equals(role)) { ...
java
{ "resource": "" }
q22071
GatewayMetrics.registerMetrics
train
public void registerMetrics(MetricsCollector metricsCollector) { SystemConfig systemConfig = (SystemConfig) SingletonRegistry.INSTANCE.getSingleton(SystemConfig.HERON_SYSTEM_CONFIG); int interval = (int) systemConfig.getHeronMetricsExportInterval().getSeconds(); metricsCollector.registerMetric("__...
java
{ "resource": "" }
q22072
MetricsManagerServer.onInternalMessage
train
public void onInternalMessage(Metrics.MetricPublisher request, Metrics.MetricPublisherPublishMessage message) { handlePublisherPublishMessage(request, message); }
java
{ "resource": "" }
q22073
TMasterSink.startTMasterChecker
train
private void startTMasterChecker() { final int checkIntervalSec = TypeUtils.getInteger(sinkConfig.get(KEY_TMASTER_LOCATION_CHECK_INTERVAL_SEC)); Runnable runnable = new Runnable() { @Override public void run() { TopologyMaster.TMasterLocation location = (TopologyMaster.T...
java
{ "resource": "" }
q22074
ZkUtils.setupZkTunnel
train
public static Pair<String, List<Process>> setupZkTunnel(Config config, NetworkUtils.TunnelConfig tunnelConfig) { // Remove all spaces String connectionString = Context.stateManagerConnectionString(config).replaceAll("\\s+", ""); List<Pair<InetSocket...
java
{ "resource": "" }
q22075
DefaultMaxSpoutPendingTuner.autoTune
train
public void autoTune(Long progress) { // LOG.info ("Called auto tune with progress " + progress); if (lastAction == ACTION.NOOP) { // We did not take any action last time if (prevProgress == -1) { // The first time around when we are called doAction(ACTION.INCREASE, autoTuneFactor, ...
java
{ "resource": "" }
q22076
HeronAnnotationProcessor.process
train
@Override public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) { if (!roundEnv.processingOver()) { for (TypeElement te : annotations) { for (Element elt : roundEnv.getElementsAnnotatedWith(te)) { if (!elt.toString().startsWith("org.apache.heron")) { ...
java
{ "resource": "" }
q22077
ConfigUtils.applyOverridesToStateManagerConfig
train
@SuppressWarnings("unchecked") public static void applyOverridesToStateManagerConfig(Path overridesPath, Path stateManagerPath) throws IOException { final Path tempStateManagerPath = Files.createTempFile("statemgr-", CONFIG_SUFFIX); Reader stateManagerReader = null; try ( Reader overrideRe...
java
{ "resource": "" }
q22078
ByteAmount.minus
train
@Override public ByteAmount minus(ResourceMeasure<Long> other) { checkArgument(Long.MIN_VALUE + other.value <= value, String.format("Subtracting %s from %s would overshoot Long.MIN_LONG", other, this)); return ByteAmount.fromBytes(value - other.value); }
java
{ "resource": "" }
q22079
ByteAmount.plus
train
@Override public ByteAmount plus(ResourceMeasure<Long> other) { checkArgument(Long.MAX_VALUE - value >= other.value, String.format("Adding %s to %s would exceed Long.MAX_LONG", other, this)); return ByteAmount.fromBytes(value + other.value); }
java
{ "resource": "" }
q22080
ByteAmount.multiply
train
@Override public ByteAmount multiply(int factor) { checkArgument(value <= Long.MAX_VALUE / factor, String.format("Multiplying %s by %d would exceed Long.MAX_LONG", this, factor)); return ByteAmount.fromBytes(value * factor); }
java
{ "resource": "" }
q22081
ByteAmount.increaseBy
train
@Override public ByteAmount increaseBy(int percentage) { checkArgument(percentage >= 0, String.format("Increasing by negative percent (%d) not supported", percentage)); double factor = 1.0 + ((double) percentage / 100); long max = Math.round(Long.MAX_VALUE / factor); checkArgument(value <= max...
java
{ "resource": "" }
q22082
SlurmController.createJob
train
public boolean createJob(String slurmScript, String heronExec, String[] commandArgs, String topologyWorkingDirectory, long containers, String partition) { // get the command to run the job on Slurm cluster List<String> slurmCmd = slurmCommand(slurmScript, he...
java
{ "resource": "" }
q22083
SlurmController.slurmCommand
train
private List<String> slurmCommand(String slurmScript, String heronExec, long containers, String partition) { String nTasks = String.format("--ntasks=%d", containers); List<String> slurmCmd; if (partition != null) { slurmCmd = new ArrayList<>(Arrays.asList("sbatch", ...
java
{ "resource": "" }
q22084
SlurmController.createJob
train
public boolean createJob(String slurmScript, String heronExec, String[] commandArgs, String topologyWorkingDirectory, long containers) { return createJob(slurmScript, heronExec, commandArgs, topologyWorkingDirectory, containers, null); }
java
{ "resource": "" }
q22085
SlurmController.runProcess
train
protected boolean runProcess(String topologyWorkingDirectory, String[] slurmCmd, StringBuilder stderr) { File file = topologyWorkingDirectory == null ? null : new File(topologyWorkingDirectory); return 0 == ShellUtils.runSyncProcess(true, false, slurmCmd, stderr, file); }
java
{ "resource": "" }
q22086
SlurmController.killJob
train
public boolean killJob(String jobIdFile) { List<String> jobIdFileContent = readFromFile(jobIdFile); if (jobIdFileContent.size() > 0) { String[] slurmCmd = new String[]{"scancel", jobIdFileContent.get(0)}; return runProcess(null, slurmCmd, new StringBuilder()); } else { LOG.log(Level.SEVERE...
java
{ "resource": "" }
q22087
SlurmController.readFromFile
train
protected List<String> readFromFile(String filename) { Path path = new File(filename).toPath(); List<String> result = new ArrayList<>(); try { List<String> tempResult = Files.readAllLines(path); if (tempResult != null) { result.addAll(tempResult); } } catch (IOException e) { ...
java
{ "resource": "" }
q22088
DownloadRunner.main
train
public static void main(String[] args) throws Exception { CommandLineParser parser = new DefaultParser(); Options slaManagerCliOptions = constructCliOptions(); // parse the help options first. Options helpOptions = constructHelpOptions(); CommandLine cmd = parser.parse(helpOptions, args, true); ...
java
{ "resource": "" }
q22089
Eco.submit
train
public void submit(FileInputStream fileInputStream, FileInputStream propertiesFile, boolean envFilter) throws Exception { EcoTopologyDefinition topologyDefinition = ecoParser .parseFromInputStream(fileInputStream, propertiesFile, envFilter); String topologyName = topologyDefi...
java
{ "resource": "" }
q22090
SysUtils.closeIgnoringExceptions
train
public static void closeIgnoringExceptions(AutoCloseable closeable) { if (closeable != null) { try { closeable.close(); // Suppress it since we ignore any exceptions // SUPPRESS CHECKSTYLE IllegalCatch } catch (Exception e) { // Still log the Exception for issue tracing ...
java
{ "resource": "" }
q22091
SchedulerConfigUtils.topologyConfigs
train
private static Config topologyConfigs(String topologyBinaryFile, String topologyDefnFile, TopologyAPI.Topology topology) { PackageType packageType = PackageType.getPackageType(topologyBinaryFile); return Config.newBuilder() .put(Key.TOPOLOGY_ID, topology.getId(...
java
{ "resource": "" }
q22092
SchedulerConfigUtils.loadConfig
train
public static Config loadConfig( String cluster, String role, String environ, String topologyBinaryFile, String topologyDefnFile, Boolean verbose, TopologyAPI.Topology topology) { return Config.toClusterMode( Config.newBuilder() .putAll(ConfigLoader.loa...
java
{ "resource": "" }
q22093
SerializationFactory.getKryo
train
@SuppressWarnings({"rawtypes", "unchecked"}) public static Kryo getKryo(Map conf) { IKryoFactory kryoFactory = (IKryoFactory) Utils.newInstance((String) conf.get(Config.TOPOLOGY_KRYO_FACTORY)); Kryo k = kryoFactory.getKryo(conf); k.register(byte[].class); k.register(ListDelegate.class); k....
java
{ "resource": "" }
q22094
LargeWaitQueueDetector.detect
train
@Override public Collection<Symptom> detect(Collection<Measurement> measurements) { Collection<Symptom> result = new ArrayList<>(); MeasurementsTable waitQueueMetrics = MeasurementsTable.of(measurements).type(METRIC_WAIT_Q_SIZE.text()); for (String component : waitQueueMetrics.uniqueComponents()...
java
{ "resource": "" }
q22095
HeronSubmitter.submitTopologyToFile
train
private static void submitTopologyToFile(TopologyAPI.Topology fTopology, Map<String, String> heronCmdOptions) { String dirName = heronCmdOptions.get(CMD_TOPOLOGY_DEFN_TEMPDIR); if (dirName == null || dirName.isEmpty()) { throw new TopologySubmissionException("Top...
java
{ "resource": "" }
q22096
SchedulerClientFactory.getSchedulerClient
train
public ISchedulerClient getSchedulerClient() throws SchedulerException { LOG.fine("Creating scheduler client"); ISchedulerClient schedulerClient; if (Context.schedulerService(config)) { // get the instance of the state manager SchedulerStateManagerAdaptor statemgr = Runtime.schedulerStateManage...
java
{ "resource": "" }
q22097
StreamletImpl.setName
train
@Override public Streamlet<R> setName(String sName) { checkNotBlank(sName, "Streamlet name cannot be null/blank"); this.name = sName; return this; }
java
{ "resource": "" }
q22098
StreamletImpl.setDefaultNameIfNone
train
protected void setDefaultNameIfNone(StreamletNamePrefix prefix, Set<String> stageNames) { if (getName() == null) { setName(defaultNameCalculator(prefix, stageNames)); } if (stageNames.contains(getName())) { throw new RuntimeException(String.format( "The stage name %s is used multiple t...
java
{ "resource": "" }
q22099
StreamletImpl.getAvailableStreamIds
train
protected Set<String> getAvailableStreamIds() { HashSet<String> ids = new HashSet<String>(); ids.add(getStreamId()); return ids; }
java
{ "resource": "" }