Search in sources :

Example 46 with HyracksException

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);
    }
}
Also used : NodeControllerInfo(org.apache.hyracks.api.client.NodeControllerInfo) HyracksException(org.apache.hyracks.api.exceptions.HyracksException) HashMap(java.util.HashMap) Map(java.util.Map) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) HyracksException(org.apache.hyracks.api.exceptions.HyracksException)

Example 47 with HyracksException

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();
}
Also used : HyracksException(org.apache.hyracks.api.exceptions.HyracksException) JobId(org.apache.hyracks.api.job.JobId) HyracksDataException(org.apache.hyracks.api.exceptions.HyracksDataException) HyracksException(org.apache.hyracks.api.exceptions.HyracksException)

Example 48 with HyracksException

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);
    }
}
Also used : HyracksException(org.apache.hyracks.api.exceptions.HyracksException) JobId(org.apache.hyracks.api.job.JobId)

Aggregations

HyracksException (org.apache.hyracks.api.exceptions.HyracksException)48 IOException (java.io.IOException)10 HyracksDataException (org.apache.hyracks.api.exceptions.HyracksDataException)8 JobId (org.apache.hyracks.api.job.JobId)8 HashMap (java.util.HashMap)7 Test (org.junit.Test)6 ArrayList (java.util.ArrayList)5 Map (java.util.Map)5 IJobCapacityController (org.apache.hyracks.api.job.resource.IJobCapacityController)5 INodeManager (org.apache.hyracks.control.cc.cluster.INodeManager)5 JobRun (org.apache.hyracks.control.cc.job.JobRun)5 URL (java.net.URL)4 AlgebricksException (org.apache.hyracks.algebricks.common.exceptions.AlgebricksException)4 NodeControllerState (org.apache.hyracks.control.cc.NodeControllerState)4 File (java.io.File)3 HashSet (java.util.HashSet)3 NodeControllerInfo (org.apache.hyracks.api.client.NodeControllerInfo)3 JobSpecification (org.apache.hyracks.api.job.JobSpecification)3 PrintWriter (java.io.PrintWriter)2 StringWriter (java.io.StringWriter)2