Java Code Examples for org.apache.flink.api.common.JobID#fromHexString()

The following examples show how to use org.apache.flink.api.common.JobID#fromHexString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JobConfigInfo.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Override
public JobConfigInfo deserialize(
		JsonParser jsonParser,
		DeserializationContext deserializationContext) throws IOException {
	JsonNode rootNode = jsonParser.readValueAsTree();

	final JobID jobId = JobID.fromHexString(rootNode.get(FIELD_NAME_JOB_ID).asText());
	final String jobName = rootNode.get(FIELD_NAME_JOB_NAME).asText();

	final ExecutionConfigInfo executionConfigInfo;

	if (rootNode.has(FIELD_NAME_EXECUTION_CONFIG)) {
		executionConfigInfo = RestMapperUtils.getStrictObjectMapper().treeToValue(rootNode.get(FIELD_NAME_EXECUTION_CONFIG), ExecutionConfigInfo.class);
	} else {
		executionConfigInfo = null;
	}

	return new JobConfigInfo(jobId, jobName, executionConfigInfo);
}
 
Example 2
Source File: JobConfigInfo.java    From flink with Apache License 2.0 6 votes vote down vote up
@Override
public JobConfigInfo deserialize(
		JsonParser jsonParser,
		DeserializationContext deserializationContext) throws IOException {
	JsonNode rootNode = jsonParser.readValueAsTree();

	final JobID jobId = JobID.fromHexString(rootNode.get(FIELD_NAME_JOB_ID).asText());
	final String jobName = rootNode.get(FIELD_NAME_JOB_NAME).asText();

	final ExecutionConfigInfo executionConfigInfo;

	if (rootNode.has(FIELD_NAME_EXECUTION_CONFIG)) {
		executionConfigInfo = RestMapperUtils.getStrictObjectMapper().treeToValue(rootNode.get(FIELD_NAME_EXECUTION_CONFIG), ExecutionConfigInfo.class);
	} else {
		executionConfigInfo = null;
	}

	return new JobConfigInfo(jobId, jobName, executionConfigInfo);
}
 
Example 3
Source File: JobsFilterQueryParameter.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public JobID convertStringToValue(String value) throws ConversionException {
	try {
		return JobID.fromHexString(value);
	} catch (IllegalArgumentException iae) {
		throw new ConversionException("Not a valid job ID: " + value, iae);
	}
}
 
Example 4
Source File: JobsFilterQueryParameter.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
@Override
public JobID convertStringToValue(String value) throws ConversionException {
	try {
		return JobID.fromHexString(value);
	} catch (IllegalArgumentException iae) {
		throw new ConversionException("Not a valid job ID: " + value, iae);
	}
}
 
Example 5
Source File: JobDetails.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
public JobDetails deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException {

	JsonNode rootNode = jsonParser.readValueAsTree();

	JobID jobId = JobID.fromHexString(rootNode.get(FIELD_NAME_JOB_ID).textValue());
	String jobName = rootNode.get(FIELD_NAME_JOB_NAME).textValue();
	long startTime = rootNode.get(FIELD_NAME_START_TIME).longValue();
	long endTime = rootNode.get(FIELD_NAME_END_TIME).longValue();
	long duration = rootNode.get(FIELD_NAME_DURATION).longValue();
	JobStatus jobStatus = JobStatus.valueOf(rootNode.get(FIELD_NAME_STATUS).textValue());
	long lastUpdateTime = rootNode.get(FIELD_NAME_LAST_MODIFICATION).longValue();

	JsonNode tasksNode = rootNode.get("tasks");
	int numTasks = tasksNode.get(FIELD_NAME_TOTAL_NUMBER_TASKS).intValue();

	int[] numVerticesPerExecutionState = new int[ExecutionState.values().length];

	for (ExecutionState executionState : ExecutionState.values()) {
		numVerticesPerExecutionState[executionState.ordinal()] = tasksNode.get(executionState.name().toLowerCase()).intValue();
	}

	return new JobDetails(
		jobId,
		jobName,
		startTime,
		endTime,
		duration,
		jobStatus,
		lastUpdateTime,
		numVerticesPerExecutionState,
		numTasks);
}
 
Example 6
Source File: StandaloneJobClusterConfigurationParserFactory.java    From flink with Apache License 2.0 5 votes vote down vote up
@Nullable
private static JobID getJobId(CommandLine commandLine) throws FlinkParseException {
	String jobId = commandLine.getOptionValue(JOB_ID_OPTION.getOpt());
	if (jobId == null) {
		return null;
	}
	try {
		return JobID.fromHexString(jobId);
	} catch (IllegalArgumentException e) {
		throw createFlinkParseException(JOB_ID_OPTION, e);
	}
}
 
Example 7
Source File: StatefulFunctionsClusterConfigurationParserFactory.java    From stateful-functions with Apache License 2.0 5 votes vote down vote up
@Nullable
private static JobID getJobId(CommandLine commandLine) throws FlinkParseException {
  String jobId = commandLine.getOptionValue(JOB_ID_OPTION.getOpt());
  if (jobId == null) {
    return null;
  }
  try {
    return JobID.fromHexString(jobId);
  } catch (IllegalArgumentException e) {
    throw createFlinkParseException(JOB_ID_OPTION, e);
  }
}
 
Example 8
Source File: StandaloneApplicationClusterConfigurationParserFactory.java    From flink with Apache License 2.0 5 votes vote down vote up
@Nullable
private static JobID getJobId(CommandLine commandLine) throws FlinkParseException {
	String jobId = commandLine.getOptionValue(JOB_ID_OPTION.getOpt());
	if (jobId == null) {
		return null;
	}
	try {
		return JobID.fromHexString(jobId);
	} catch (IllegalArgumentException e) {
		throw createFlinkParseException(JOB_ID_OPTION, e);
	}
}
 
Example 9
Source File: JobIDPathParameter.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected JobID convertFromString(String value) {
	return JobID.fromHexString(value);
}
 
Example 10
Source File: JobIDDeserializer.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public JobID deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
	return JobID.fromHexString(p.getValueAsString());
}
 
Example 11
Source File: HistoryServerArchiveFetcher.java    From flink with Apache License 2.0 4 votes vote down vote up
private static String convertLegacyJobOverview(String legacyOverview) throws IOException {
	JsonNode root = mapper.readTree(legacyOverview);
	JsonNode finishedJobs = root.get("finished");
	JsonNode job = finishedJobs.get(0);

	JobID jobId = JobID.fromHexString(job.get("jid").asText());
	String name = job.get("name").asText();
	JobStatus state = JobStatus.valueOf(job.get("state").asText());

	long startTime = job.get("start-time").asLong();
	long endTime = job.get("end-time").asLong();
	long duration = job.get("duration").asLong();
	long lastMod = job.get("last-modification").asLong();

	JsonNode tasks = job.get("tasks");
	int numTasks = tasks.get("total").asInt();
	JsonNode pendingNode = tasks.get("pending");
	// for flink version < 1.4 we have pending field,
	// when version >= 1.4 pending has been split into scheduled, deploying, and created.
	boolean versionLessThan14 = pendingNode != null;
	int created = 0;
	int scheduled;
	int deploying = 0;

	if (versionLessThan14) {
		// pending is a mix of CREATED/SCHEDULED/DEPLOYING
		// to maintain the correct number of task states we pick SCHEDULED
		scheduled = pendingNode.asInt();
	} else {
		created = tasks.get("created").asInt();
		scheduled = tasks.get("scheduled").asInt();
		deploying = tasks.get("deploying").asInt();
	}
	int running = tasks.get("running").asInt();
	int finished = tasks.get("finished").asInt();
	int canceling = tasks.get("canceling").asInt();
	int canceled = tasks.get("canceled").asInt();
	int failed = tasks.get("failed").asInt();

	int[] tasksPerState = new int[ExecutionState.values().length];
	tasksPerState[ExecutionState.CREATED.ordinal()] = created;
	tasksPerState[ExecutionState.SCHEDULED.ordinal()] = scheduled;
	tasksPerState[ExecutionState.DEPLOYING.ordinal()] = deploying;
	tasksPerState[ExecutionState.RUNNING.ordinal()] = running;
	tasksPerState[ExecutionState.FINISHED.ordinal()] = finished;
	tasksPerState[ExecutionState.CANCELING.ordinal()] = canceling;
	tasksPerState[ExecutionState.CANCELED.ordinal()] = canceled;
	tasksPerState[ExecutionState.FAILED.ordinal()] = failed;

	JobDetails jobDetails = new JobDetails(jobId, name, startTime, endTime, duration, state, lastMod, tasksPerState, numTasks);
	MultipleJobsDetails multipleJobsDetails = new MultipleJobsDetails(Collections.singleton(jobDetails));

	StringWriter sw = new StringWriter();
	mapper.writeValue(sw, multipleJobsDetails);
	return sw.toString();
}
 
Example 12
Source File: RestServerEndpointITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public JobID convertStringToValue(String value) {
	return JobID.fromHexString(value);
}
 
Example 13
Source File: RestServerEndpointITCase.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public JobID convertFromString(String value) {
	return JobID.fromHexString(value);
}
 
Example 14
Source File: RestServerEndpointITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
protected JobID convertFromString(String value) throws ConversionException {
	return JobID.fromHexString(value);
}
 
Example 15
Source File: MessageParametersTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
public JobID convertFromString(String value) {
	return JobID.fromHexString(value);
}
 
Example 16
Source File: RestServerEndpointITCase.java    From flink with Apache License 2.0 4 votes vote down vote up
@Override
public JobID convertFromString(String value) {
	return JobID.fromHexString(value);
}
 
Example 17
Source File: JobIDPathParameter.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Override
protected JobID convertFromString(String value) {
	return JobID.fromHexString(value);
}
 
Example 18
Source File: HistoryServerArchiveFetcher.java    From flink with Apache License 2.0 4 votes vote down vote up
private static String convertLegacyJobOverview(String legacyOverview) throws IOException {
	JsonNode root = mapper.readTree(legacyOverview);
	JsonNode finishedJobs = root.get("finished");
	JsonNode job = finishedJobs.get(0);

	JobID jobId = JobID.fromHexString(job.get("jid").asText());
	String name = job.get("name").asText();
	JobStatus state = JobStatus.valueOf(job.get("state").asText());

	long startTime = job.get("start-time").asLong();
	long endTime = job.get("end-time").asLong();
	long duration = job.get("duration").asLong();
	long lastMod = job.get("last-modification").asLong();

	JsonNode tasks = job.get("tasks");
	int numTasks = tasks.get("total").asInt();
	JsonNode pendingNode = tasks.get("pending");
	// for flink version < 1.4 we have pending field,
	// when version >= 1.4 pending has been split into scheduled, deploying, and created.
	boolean versionLessThan14 = pendingNode != null;
	int created = 0;
	int scheduled;
	int deploying = 0;

	if (versionLessThan14) {
		// pending is a mix of CREATED/SCHEDULED/DEPLOYING
		// to maintain the correct number of task states we pick SCHEDULED
		scheduled = pendingNode.asInt();
	} else {
		created = tasks.get("created").asInt();
		scheduled = tasks.get("scheduled").asInt();
		deploying = tasks.get("deploying").asInt();
	}
	int running = tasks.get("running").asInt();
	int finished = tasks.get("finished").asInt();
	int canceling = tasks.get("canceling").asInt();
	int canceled = tasks.get("canceled").asInt();
	int failed = tasks.get("failed").asInt();

	int[] tasksPerState = new int[ExecutionState.values().length];
	tasksPerState[ExecutionState.CREATED.ordinal()] = created;
	tasksPerState[ExecutionState.SCHEDULED.ordinal()] = scheduled;
	tasksPerState[ExecutionState.DEPLOYING.ordinal()] = deploying;
	tasksPerState[ExecutionState.RUNNING.ordinal()] = running;
	tasksPerState[ExecutionState.FINISHED.ordinal()] = finished;
	tasksPerState[ExecutionState.CANCELING.ordinal()] = canceling;
	tasksPerState[ExecutionState.CANCELED.ordinal()] = canceled;
	tasksPerState[ExecutionState.FAILED.ordinal()] = failed;

	JobDetails jobDetails = new JobDetails(jobId, name, startTime, endTime, duration, state, lastMod, tasksPerState, numTasks);
	MultipleJobsDetails multipleJobsDetails = new MultipleJobsDetails(Collections.singleton(jobDetails));

	StringWriter sw = new StringWriter();
	mapper.writeValue(sw, multipleJobsDetails);
	return sw.toString();
}
 
Example 19
Source File: ZooKeeperJobGraphStore.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * Returns a JobID for the event's path.
 */
private JobID fromEvent(PathChildrenCacheEvent event) {
	return JobID.fromHexString(ZKPaths.getNodeFromPath(event.getData().getPath()));
}
 
Example 20
Source File: HistoryServerArchiveFetcher.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
private static String convertLegacyJobOverview(String legacyOverview) throws IOException {
	JsonNode root = mapper.readTree(legacyOverview);
	JsonNode finishedJobs = root.get("finished");
	JsonNode job = finishedJobs.get(0);

	JobID jobId = JobID.fromHexString(job.get("jid").asText());
	String name = job.get("name").asText();
	JobStatus state = JobStatus.valueOf(job.get("state").asText());

	long startTime = job.get("start-time").asLong();
	long endTime = job.get("end-time").asLong();
	long duration = job.get("duration").asLong();
	long lastMod = job.get("last-modification").asLong();

	JsonNode tasks = job.get("tasks");
	int numTasks = tasks.get("total").asInt();
	JsonNode pendingNode = tasks.get("pending");
	// for flink version < 1.4 we have pending field,
	// when version >= 1.4 pending has been split into scheduled, deploying, and created.
	boolean versionLessThan14 = pendingNode != null;
	int created = 0;
	int scheduled;
	int deploying = 0;

	if (versionLessThan14) {
		// pending is a mix of CREATED/SCHEDULED/DEPLOYING
		// to maintain the correct number of task states we pick SCHEDULED
		scheduled = pendingNode.asInt();
	} else {
		created = tasks.get("created").asInt();
		scheduled = tasks.get("scheduled").asInt();
		deploying = tasks.get("deploying").asInt();
	}
	int running = tasks.get("running").asInt();
	int finished = tasks.get("finished").asInt();
	int canceling = tasks.get("canceling").asInt();
	int canceled = tasks.get("canceled").asInt();
	int failed = tasks.get("failed").asInt();

	int[] tasksPerState = new int[ExecutionState.values().length];
	tasksPerState[ExecutionState.CREATED.ordinal()] = created;
	tasksPerState[ExecutionState.SCHEDULED.ordinal()] = scheduled;
	tasksPerState[ExecutionState.DEPLOYING.ordinal()] = deploying;
	tasksPerState[ExecutionState.RUNNING.ordinal()] = running;
	tasksPerState[ExecutionState.FINISHED.ordinal()] = finished;
	tasksPerState[ExecutionState.CANCELING.ordinal()] = canceling;
	tasksPerState[ExecutionState.CANCELED.ordinal()] = canceled;
	tasksPerState[ExecutionState.FAILED.ordinal()] = failed;

	JobDetails jobDetails = new JobDetails(jobId, name, startTime, endTime, duration, state, lastMod, tasksPerState, numTasks);
	MultipleJobsDetails multipleJobsDetails = new MultipleJobsDetails(Collections.singleton(jobDetails));

	StringWriter sw = new StringWriter();
	mapper.writeValue(sw, multipleJobsDetails);
	return sw.toString();
}