use of org.apache.hyracks.api.partitions.IPartition in project asterixdb by apache.
the class PartitionManager method unregisterPartitions.
public synchronized void unregisterPartitions(JobId jobId, Collection<IPartition> unregisteredPartitions) {
for (Iterator<Map.Entry<PartitionId, List<IPartition>>> i = availablePartitionMap.entrySet().iterator(); i.hasNext(); ) {
Map.Entry<PartitionId, List<IPartition>> e = i.next();
PartitionId pid = e.getKey();
if (jobId.equals(pid.getJobId())) {
for (IPartition p : e.getValue()) {
unregisteredPartitions.add(p);
}
i.remove();
}
}
}
use of org.apache.hyracks.api.partitions.IPartition in project asterixdb by apache.
the class PartitionManager method registerPartitionRequest.
public synchronized void registerPartitionRequest(PartitionId partitionId, NetworkOutputChannel writer) throws HyracksException {
try {
List<IPartition> pList = availablePartitionMap.get(partitionId);
if (pList != null && !pList.isEmpty()) {
IPartition partition = pList.get(0);
writer.setFrameSize(partition.getTaskContext().getInitialFrameSize());
partition.writeTo(writer);
if (!partition.isReusable()) {
availablePartitionMap.remove(partitionId);
}
} else {
//throw new HyracksException("Request for unknown partition " + partitionId);
partitionRequests.put(partitionId, writer);
}
} catch (Exception e) {
throw new HyracksDataException(e);
}
}
use of org.apache.hyracks.api.partitions.IPartition in project asterixdb by apache.
the class PartitionManager method registerPartition.
public synchronized void registerPartition(PartitionId pid, TaskAttemptId taId, IPartition partition, PartitionState state, boolean updateToCC) throws HyracksDataException {
try {
/**
* process pending requests
*/
NetworkOutputChannel writer = partitionRequests.remove(pid);
if (writer != null) {
writer.setFrameSize(partition.getTaskContext().getInitialFrameSize());
partition.writeTo(writer);
if (!partition.isReusable()) {
return;
}
}
/**
* put a coming available partition into the available partition map
*/
List<IPartition> pList = availablePartitionMap.get(pid);
if (pList == null) {
pList = new ArrayList<>();
availablePartitionMap.put(pid, pList);
}
pList.add(partition);
/**
* update to CC only when necessary
*/
if (updateToCC) {
updatePartitionState(pid, taId, partition, state);
}
} catch (Exception e) {
throw new HyracksDataException(e);
}
}
use of org.apache.hyracks.api.partitions.IPartition in project asterixdb by apache.
the class CleanupJobletWork method run.
@Override
public void run() {
if (LOGGER.isLoggable(Level.INFO)) {
LOGGER.info("Cleaning up after job: " + jobId);
}
final List<IPartition> unregisteredPartitions = new ArrayList<IPartition>();
ncs.getPartitionManager().unregisterPartitions(jobId, unregisteredPartitions);
ncs.getExecutor().execute(new Runnable() {
@Override
public void run() {
for (IPartition p : unregisteredPartitions) {
try {
// Put deallocate in a try block to make sure that every IPartition is de-allocated.
p.deallocate();
} catch (Exception e) {
if (LOGGER.isLoggable(Level.WARNING)) {
LOGGER.log(Level.WARNING, e.getMessage(), e);
}
}
}
}
});
Map<JobId, Joblet> jobletMap = ncs.getJobletMap();
Joblet joblet = jobletMap.remove(jobId);
if (joblet != null) {
joblet.cleanup(status);
}
}
use of org.apache.hyracks.api.partitions.IPartition in project asterixdb by apache.
the class MaterializedPartitionInputChannel method open.
@Override
public void open(IHyracksCommonContext ctx) throws HyracksDataException {
for (int i = 0; i < nBuffers; ++i) {
emptyQueue.add(ctx.allocateFrame());
}
IPartition partition = manager.getPartition(pid);
partition.writeTo(writer);
}
Aggregations