Example usage for org.apache.hadoop.yarn.exceptions YarnException YarnException

List of usage examples for org.apache.hadoop.yarn.exceptions YarnException YarnException

Introduction

In this page you can find the example usage for org.apache.hadoop.yarn.exceptions YarnException YarnException.

Prototype

public YarnException() 

Source Link

Usage

From source file:edu.uci.ics.asterix.aoya.AsterixYARNClient.java

License:Apache License

/**
 * Start a YARN job to delete local AsterixDB resources of an extant instance
 * @param app The Client connection/*from   ww  w.  j  a v a  2 s  .  co m*/
 * @param resources AM resources
 * @throws IOException
 * @throws YarnException
 */

private void removeInstance(YarnClientApplication app, List<DFSResourceCoordinate> resources)
        throws IOException, YarnException {
    FileSystem fs = FileSystem.get(conf);
    //if the instance is up, fix that
    stopInstanceIfRunning();
    //now try deleting all of the on-disk artifacts on the cluster
    ApplicationId deleter = deployAM(app, resources, Mode.DESTROY);
    boolean delete_start = Utils.waitForApplication(deleter, yarnClient, "Waiting for deletion to start",
            ccRestPort);
    if (!delete_start) {
        if (force) {
            fs.delete(new Path(CONF_DIR_REL + instanceFolder), true);
            LOG.error("Forcing deletion of HDFS resources");
        }
        LOG.fatal(" of on-disk persistient resources on individual nodes failed.");
        throw new YarnException();
    }
    boolean deleted = waitForCompletion(deleter, "Deletion in progress");
    if (!(deleted || force)) {
        LOG.fatal("Cleanup of on-disk persistent resources failed.");
        return;
    } else {
        fs.delete(new Path(CONF_DIR_REL + instanceFolder), true);
    }
    System.out.println("Deletion of instance succeeded.");

}

From source file:edu.uci.ics.asterix.aoya.AsterixYARNClient.java

License:Apache License

/**
 * Start a YARN job to copy all data-containing resources of an AsterixDB instance to HDFS
 * @param app//from  w ww  .  j  a v a 2 s .c om
 * @param resources
 * @throws IOException
 * @throws YarnException
 */

private void backupInstance(YarnClientApplication app, List<DFSResourceCoordinate> resources)
        throws IOException, YarnException {
    stopInstanceIfRunning();
    ApplicationId backerUpper = deployAM(app, resources, Mode.BACKUP);
    boolean backupStart;
    backupStart = Utils.waitForApplication(backerUpper, yarnClient,
            "Waiting for backup " + backerUpper.toString() + "to start", ccRestPort);
    if (!backupStart) {
        LOG.fatal("Backup failed to start");
        throw new YarnException();
    }
    boolean complete;
    complete = waitForCompletion(backerUpper, "Backup in progress");
    if (!complete) {
        LOG.fatal("Backup failed- timeout waiting for completion");
        return;
    }
    System.out.println("Backup of instance succeeded.");
}

From source file:edu.uci.ics.asterix.aoya.AsterixYARNClient.java

License:Apache License

/**
 * Start a YARN job to copy a set of resources from backupInstance to restore the state of an extant AsterixDB instance
 * @param app/*from  w  w  w.java 2s.  co m*/
 * @param resources
 * @throws IOException
 * @throws YarnException
 */

private void restoreInstance(YarnClientApplication app, List<DFSResourceCoordinate> resources)
        throws IOException, YarnException {
    stopInstanceIfRunning();
    ApplicationId restorer = deployAM(app, resources, Mode.RESTORE);
    boolean restoreStart = Utils.waitForApplication(restorer, yarnClient, "Waiting for restore to start",
            ccRestPort);
    if (!restoreStart) {
        LOG.fatal("Restore failed to start");
        throw new YarnException();
    }
    boolean complete = waitForCompletion(restorer, "Restore in progress");
    if (!complete) {
        LOG.fatal("Restore failed- timeout waiting for completion");
        return;
    }
    System.out.println("Restoration of instance succeeded.");
}

From source file:org.trustedanalytics.servicebroker.h2oprovisioner.cdhclients.DeprovisionerYarnClientTest.java

License:Apache License

@Test
public void getH2oJobId_ExceptionThrownFromYarnClient_ExceptionThrown() throws Exception {
    // given//from   www  .  ja v a  2  s.c om
    when(yarnClientMock.getApplications(expectedApplicationType, expectedApplicationState))
            .thenThrow(new YarnException());
    DeprovisionerYarnClient sut = new DeprovisionerYarnClient(yarnClientMock);

    // when
    // then
    thrown.expect(YarnException.class);
    thrown.expectMessage("Error obtaining H2O job id from YARN");
    sut.getH2oJobId(testServiceInstanceId);

}

From source file:org.trustedanalytics.servicebroker.h2oprovisioner.service.H2oDeprovisionerTest.java

License:Apache License

@Test
public void deprovisionInstanceForKrb_YarnClientWhenGettingJobIdThrowsYarnException_ExceptionThrown()
        throws Exception {
    // given/*from   ww w .ja v  a  2s.c  om*/
    when(yarnClientMock.getH2oJobId(testInstanceId)).thenThrow(new YarnException());
    H2oDeprovisioner sut = new H2oDeprovisioner(kerberosUser, kerberosClientMock, yarnClientProviderMock,
            hadoopConf);

    // when
    //then
    thrown.expect(H2oDeprovisioningException.class);
    sut.deprovisionInstance(testInstanceId);
}

From source file:org.trustedanalytics.servicebroker.h2oprovisioner.service.H2oDeprovisionerTest.java

License:Apache License

@Test
public void deprovisionInstanceForKrb_YarnClientWhenKillingJobThrowsYarnException_ExceptionThrown()
        throws Exception {
    // given/*from w  w w .j av  a  2s .c o  m*/
    doThrow(new YarnException()).when(yarnClientMock).killApplication(applicationIdMock);
    H2oDeprovisioner sut = new H2oDeprovisioner(kerberosUser, kerberosClientMock, yarnClientProviderMock,
            hadoopConf);

    // when
    //then
    thrown.expect(H2oDeprovisioningException.class);
    sut.deprovisionInstance(testInstanceId);
}