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

The following examples show how to use org.apache.flink.api.common.JobID#equals() . 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: TaskSlot.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Allocate the task slot for the given job and allocation id. If the slot could be allocated,
 * or is already allocated/active for the given job and allocation id, then the method returns
 * true. Otherwise it returns false.
 *
 * <p>A slot can only be allocated if it's current state is free.
 *
 * @param newJobId to allocate the slot for
 * @param newAllocationId to identify the slot allocation
 * @return True if the slot was allocated for the given job and allocation id; otherwise false
 */
public boolean allocate(JobID newJobId, AllocationID newAllocationId) {
	if (TaskSlotState.FREE == state) {
		// sanity checks
		Preconditions.checkState(allocationId == null);
		Preconditions.checkState(jobId == null);

		this.jobId = Preconditions.checkNotNull(newJobId);
		this.allocationId = Preconditions.checkNotNull(newAllocationId);

		state = TaskSlotState.ALLOCATED;

		return true;
	} else if (TaskSlotState.ALLOCATED == state || TaskSlotState.ACTIVE == state) {
		Preconditions.checkNotNull(newJobId);
		Preconditions.checkNotNull(newAllocationId);

		return newJobId.equals(jobId) && newAllocationId.equals(allocationId);
	} else {
		return false;
	}
}
 
Example 2
Source File: TaskSlot.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Allocate the task slot for the given job and allocation id. If the slot could be allocated,
 * or is already allocated/active for the given job and allocation id, then the method returns
 * true. Otherwise it returns false.
 *
 * <p>A slot can only be allocated if it's current state is free.
 *
 * @param newJobId to allocate the slot for
 * @param newAllocationId to identify the slot allocation
 * @return True if the slot was allocated for the given job and allocation id; otherwise false
 */
public boolean allocate(JobID newJobId, AllocationID newAllocationId) {
	if (TaskSlotState.FREE == state) {
		// sanity checks
		Preconditions.checkState(allocationId == null);
		Preconditions.checkState(jobId == null);

		this.jobId = Preconditions.checkNotNull(newJobId);
		this.allocationId = Preconditions.checkNotNull(newAllocationId);

		state = TaskSlotState.ALLOCATED;

		return true;
	} else if (TaskSlotState.ALLOCATED == state || TaskSlotState.ACTIVE == state) {
		Preconditions.checkNotNull(newJobId);
		Preconditions.checkNotNull(newAllocationId);

		return newJobId.equals(jobId) && newAllocationId.equals(allocationId);
	} else {
		return false;
	}
}
 
Example 3
Source File: TaskSlot.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public boolean isActive(JobID activeJobId, AllocationID activeAllocationId) {
	Preconditions.checkNotNull(activeJobId);
	Preconditions.checkNotNull(activeAllocationId);

	return TaskSlotState.ACTIVE == state &&
		activeJobId.equals(jobId) &&
		activeAllocationId.equals(allocationId);
}
 
Example 4
Source File: TaskSlot.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
public boolean isAllocated(JobID jobIdToCheck, AllocationID allocationIDToCheck) {
	Preconditions.checkNotNull(jobIdToCheck);
	Preconditions.checkNotNull(allocationIDToCheck);

	return jobIdToCheck.equals(jobId) && allocationIDToCheck.equals(allocationId) &&
		(TaskSlotState.ACTIVE == state || TaskSlotState.ALLOCATED == state);
}
 
Example 5
Source File: TaskSlot.java    From flink with Apache License 2.0 5 votes vote down vote up
public boolean isActive(JobID activeJobId, AllocationID activeAllocationId) {
	Preconditions.checkNotNull(activeJobId);
	Preconditions.checkNotNull(activeAllocationId);

	return TaskSlotState.ACTIVE == state &&
		activeJobId.equals(jobId) &&
		activeAllocationId.equals(allocationId);
}
 
Example 6
Source File: TaskSlot.java    From flink with Apache License 2.0 5 votes vote down vote up
public boolean isAllocated(JobID jobIdToCheck, AllocationID allocationIDToCheck) {
	Preconditions.checkNotNull(jobIdToCheck);
	Preconditions.checkNotNull(allocationIDToCheck);

	return jobIdToCheck.equals(jobId) && allocationIDToCheck.equals(allocationId) &&
		(TaskSlotState.ACTIVE == state || TaskSlotState.ALLOCATED == state);
}
 
Example 7
Source File: TaskSlot.java    From flink with Apache License 2.0 5 votes vote down vote up
public boolean isActive(JobID activeJobId, AllocationID activeAllocationId) {
	Preconditions.checkNotNull(activeJobId);
	Preconditions.checkNotNull(activeAllocationId);

	return TaskSlotState.ACTIVE == state &&
		activeJobId.equals(jobId) &&
		activeAllocationId.equals(allocationId);
}
 
Example 8
Source File: TaskSlot.java    From flink with Apache License 2.0 5 votes vote down vote up
public boolean isAllocated(JobID jobIdToCheck, AllocationID allocationIDToCheck) {
	Preconditions.checkNotNull(jobIdToCheck);
	Preconditions.checkNotNull(allocationIDToCheck);

	return jobIdToCheck.equals(jobId) && allocationIDToCheck.equals(allocationId) &&
		(TaskSlotState.ACTIVE == state || TaskSlotState.ALLOCATED == state);
}