use of org.apache.hyracks.api.exceptions.HyracksException in project asterixdb by apache.
the class Scheduler method loadIPAddressToNCMap.
/**
* Load the IP-address-to-NC map from the NCNameToNCInfoMap
*
* @param ncNameToNcInfos
* @throws HyracksException
*/
private void loadIPAddressToNCMap(Map<String, NodeControllerInfo> ncNameToNcInfos) throws HyracksException {
try {
NCs = new String[ncNameToNcInfos.size()];
ipToNcMapping.clear();
ncNameToIndex.clear();
int i = 0;
/**
* build the IP address to NC map
*/
for (Map.Entry<String, NodeControllerInfo> entry : ncNameToNcInfos.entrySet()) {
String ipAddr = InetAddress.getByAddress(entry.getValue().getNetworkAddress().lookupIpAddress()).getHostAddress();
List<String> matchedNCs = ipToNcMapping.get(ipAddr);
if (matchedNCs == null) {
matchedNCs = new ArrayList<String>();
ipToNcMapping.put(ipAddr, matchedNCs);
}
matchedNCs.add(entry.getKey());
NCs[i] = entry.getKey();
i++;
}
/**
* set up the NC name to index mapping
*/
for (i = 0; i < NCs.length; i++) {
ncNameToIndex.put(NCs[i], i);
}
} catch (Exception e) {
throw new HyracksException(e);
}
}
use of org.apache.hyracks.api.exceptions.HyracksException in project asterixdb by apache.
the class SleepOperatorDescriptor method cancelAfterWaitForCompletion.
private void cancelAfterWaitForCompletion(JobSpecification spec) throws Exception {
JobId jobId = startJob(spec);
// A thread for canceling the job.
Thread thread = new Thread(() -> {
try {
synchronized (this) {
// Make sure waitForCompletion be called first.
this.wait(500);
}
cancelJob(jobId);
} catch (Exception e) {
e.printStackTrace();
}
});
// Cancels the job.
thread.start();
// Checks the resulting Exception.
boolean exceptionMatched = false;
try {
waitForCompletion(jobId);
} catch (Exception e) {
exceptionMatched = true;
Assert.assertTrue(e instanceof HyracksException);
HyracksException hyracksException = (HyracksException) e;
Assert.assertTrue(hyracksException.getErrorCode() == ErrorCode.JOB_CANCELED);
} finally {
Assert.assertTrue(exceptionMatched);
}
thread.join();
}
use of org.apache.hyracks.api.exceptions.HyracksException in project asterixdb by apache.
the class SleepOperatorDescriptor method cancelBeforeWaitForCompletion.
private void cancelBeforeWaitForCompletion(JobSpecification spec) throws Exception {
boolean exceptionMatched = false;
try {
JobId jobId = startJob(spec);
cancelJob(jobId);
waitForCompletion(jobId);
} catch (HyracksException e) {
exceptionMatched = true;
Assert.assertTrue(e.getErrorCode() == ErrorCode.JOB_CANCELED);
} finally {
Assert.assertTrue(exceptionMatched);
}
}
Aggregations