Example usage for java.rmi RemoteException getMessage

List of usage examples for java.rmi RemoteException getMessage

Introduction

In this page you can find the example usage for java.rmi RemoteException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message, including the message from the cause, if any, of this exception.

Usage

From source file:org.apache.stratos.rest.endpoint.api.StratosApiV41Utils.java

/**
 * Deploy application with an application policy.
 *
 * @param applicationId       Application ID
 * @param applicationPolicyId Application policy Id
 * @throws RestAPIException/*from   w  w  w.  ja va 2s .c o m*/
 */
public static void deployApplication(String applicationId, String applicationPolicyId) throws RestAPIException {

    if (StringUtils.isEmpty(applicationPolicyId)) {
        String message = "Application policy id is Empty";
        log.error(message);
        throw new RestAPIException(message);
    }

    try {
        if (log.isInfoEnabled()) {
            log.info(String.format("Starting to deploy application: [application-id] %s", applicationId));
        }

        AutoscalerServiceClient autoscalerServiceClient = getAutoscalerServiceClient();
        ApplicationContext application = autoscalerServiceClient.getApplication(applicationId);

        if (application == null) {
            String message = String.format("Application not found: [application-id] %s", applicationId);
            log.error(message);
            throw new RestAPIException(message);
        }

        if (application.getStatus().equalsIgnoreCase(APPLICATION_STATUS_DEPLOYED)) {
            String message = String.format(
                    "Application is already in DEPLOYED state: [application-id] %s [current status] %s ",
                    applicationId, application.getStatus());
            log.error(message);
            throw new ApplicationAlreadyDeployedException(message);
        }

        // This is a redundant state since there is only CREATED,DEPLOYED state.
        // But this will be usefull when more status are added.
        if (!application.getStatus().equalsIgnoreCase(APPLICATION_STATUS_CREATED)) {
            String message = String.format(
                    "Application is not in CREATED state: [application-id] %s [current status] %s ",
                    applicationId, application.getStatus());
            log.error(message);
            throw new RestAPIException(message);
        }

        ApplicationBean applicationBean = getApplication(applicationId);
        int tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
        if (applicationBean.isMultiTenant() && (tenantId != -1234)) {
            String message = String.format(
                    "Multi-tenant applications can only be deployed by super tenant: [application-id] %s",
                    applicationId);
            log.error(message);
            throw new RestAPIException(message);
        }

        autoscalerServiceClient.deployApplication(applicationId, applicationPolicyId);
        if (log.isInfoEnabled()) {
            log.info(String.format("Application deployed successfully: [application-id] %s", applicationId));
        }
    } catch (RemoteException e) {
        log.error(e.getMessage(), e);
        throw new RestAPIException(e.getMessage(), e);
    } catch (AutoscalerServiceInvalidPolicyExceptionException e) {
        String message = e.getFaultMessage().getInvalidPolicyException().getMessage();
        log.error(message, e);
        throw new RestAPIException(message, e);
    } catch (AutoscalerServiceApplicationDefinitionExceptionException e) {
        String message = e.getMessage();
        log.error(message, e);
        throw new RestAPIException(message, e);
    }
}

From source file:org.apache.stratos.rest.endpoint.api.StratosApiV41Utils.java

/**
 * Add Kubernetes Cluster//  w ww .  ja v  a  2s .c  o  m
 *
 * @param kubernetesClusterBean KubernetesClusterBean
 * @return add status
 * @throws RestAPIException
 */
public static boolean addKubernetesCluster(KubernetesClusterBean kubernetesClusterBean)
        throws RestAPIException, CloudControllerServiceInvalidKubernetesClusterExceptionException,
        CloudControllerServiceKubernetesClusterAlreadyExistsExceptionException {

    CloudControllerServiceClient cloudControllerServiceClient = getCloudControllerServiceClient();
    if (cloudControllerServiceClient != null) {
        org.apache.stratos.cloud.controller.stub.domain.kubernetes.KubernetesCluster kubernetesCluster = ObjectConverter
                .convertToCCKubernetesClusterPojo(kubernetesClusterBean);

        try {
            return cloudControllerServiceClient.deployKubernetesCluster(kubernetesCluster);
        } catch (RemoteException e) {
            log.error(e.getMessage(), e);
            throw new RestAPIException(e.getMessage(), e);
        }
    }
    return false;
}

From source file:org.apache.stratos.rest.endpoint.api.StratosApiV41Utils.java

/**
 * Update Kubernetes Cluster//from  ww  w.j  a va 2  s  . c o m
 *
 * @param kubernetesClusterBean KubernetesClusterBean
 * @return add status
 * @throws RestAPIException
 */
public static boolean updateKubernetesCluster(KubernetesClusterBean kubernetesClusterBean)
        throws RestAPIException, CloudControllerServiceInvalidKubernetesClusterExceptionException {

    CloudControllerServiceClient cloudControllerServiceClient = getCloudControllerServiceClient();
    if (cloudControllerServiceClient != null) {
        org.apache.stratos.cloud.controller.stub.domain.kubernetes.KubernetesCluster kubernetesCluster = ObjectConverter
                .convertToCCKubernetesClusterPojo(kubernetesClusterBean);

        try {
            return cloudControllerServiceClient.updateKubernetesCluster(kubernetesCluster);
        } catch (RemoteException e) {
            log.error(e.getMessage(), e);
            throw new RestAPIException(e.getMessage(), e);
        }
    }
    return false;
}

From source file:org.apache.stratos.rest.endpoint.api.StratosApiV41Utils.java

/**
 * Add Kubernetes Host/*  w  ww . j a v a 2s  . c o  m*/
 *
 * @param kubernetesClusterId KubernetesClusterId
 * @param kubernetesHostBean  KubernetesHostBean
 * @return add status
 * @throws RestAPIException
 */
public static boolean addKubernetesHost(String kubernetesClusterId, KubernetesHostBean kubernetesHostBean)
        throws RestAPIException {

    CloudControllerServiceClient cloudControllerServiceClient = getCloudControllerServiceClient();
    if (cloudControllerServiceClient != null) {
        org.apache.stratos.cloud.controller.stub.domain.kubernetes.KubernetesHost kubernetesHost = ObjectConverter
                .convertKubernetesHostToStubKubernetesHost(kubernetesHostBean);

        try {
            return cloudControllerServiceClient.addKubernetesHost(kubernetesClusterId, kubernetesHost);
        } catch (RemoteException e) {
            log.error(e.getMessage(), e);
            throw new RestAPIException(e.getMessage(), e);
        } catch (CloudControllerServiceInvalidKubernetesHostExceptionException e) {
            String message = e.getFaultMessage().getInvalidKubernetesHostException().getMessage();
            log.error(message, e);
            throw new RestAPIException(message, e);
        } catch (CloudControllerServiceNonExistingKubernetesClusterExceptionException e) {
            String message = e.getFaultMessage().getNonExistingKubernetesClusterException().getMessage();
            log.error(message, e);
            throw new RestAPIException(message, e);
        }
    }
    return false;
}

From source file:org.apache.stratos.rest.endpoint.api.StratosApiV41Utils.java

/**
 * Update Kubernetes Master/*from w  w  w.j  a  v a 2  s.  com*/
 *
 * @param kubernetesMasterBean KubernetesMasterBean
 * @return update status
 * @throws RestAPIException
 */
public static boolean updateKubernetesMaster(KubernetesMasterBean kubernetesMasterBean)
        throws RestAPIException {

    CloudControllerServiceClient cloudControllerServiceClient = getCloudControllerServiceClient();
    if (cloudControllerServiceClient != null) {
        org.apache.stratos.cloud.controller.stub.domain.kubernetes.KubernetesMaster kubernetesMaster = ObjectConverter
                .convertStubKubernetesMasterToKubernetesMaster(kubernetesMasterBean);

        try {
            return cloudControllerServiceClient.updateKubernetesMaster(kubernetesMaster);
        } catch (RemoteException e) {
            log.error(e.getMessage(), e);
            throw new RestAPIException(e.getMessage(), e);
        } catch (CloudControllerServiceInvalidKubernetesMasterExceptionException e) {
            String message = e.getFaultMessage().getInvalidKubernetesMasterException().getMessage();
            log.error(message, e);
            throw new RestAPIException(message, e);
        } catch (CloudControllerServiceNonExistingKubernetesMasterExceptionException e) {
            String message = e.getFaultMessage().getNonExistingKubernetesMasterException().getMessage();
            log.error(message, e);
            throw new RestAPIException(message, e);
        }
    }
    return false;
}

From source file:org.apache.stratos.rest.endpoint.api.StratosApiV41Utils.java

/**
 * Get Available Kubernetes Clusters// w  ww  .j  a  v a 2 s.  c  o m
 *
 * @return Array of KubernetesClusterBeans
 * @throws RestAPIException
 */
public static KubernetesClusterBean[] getAvailableKubernetesClusters() throws RestAPIException {

    CloudControllerServiceClient cloudControllerServiceClient = getCloudControllerServiceClient();
    if (cloudControllerServiceClient != null) {
        try {
            org.apache.stratos.cloud.controller.stub.domain.kubernetes.KubernetesCluster[] kubernetesClusters = cloudControllerServiceClient
                    .getAvailableKubernetesClusters();
            if (kubernetesClusters == null) {
                if (log.isDebugEnabled()) {
                    log.debug("There are no available Kubernetes clusters");
                }

                return null;
            }

            return ObjectConverter.convertStubKubernetesClustersToKubernetesClusters(kubernetesClusters);

        } catch (RemoteException e) {
            log.error(e.getMessage(), e);
            throw new RestAPIException(e.getMessage(), e);
        }
    }
    return null;
}

From source file:org.apache.stratos.rest.endpoint.api.StratosApiV41Utils.java

/**
 * Get a Kubernetes Cluster//from   w  w w. j  av a 2  s . c o m
 *
 * @param kubernetesClusterId Cluster ID
 * @return KubernetesClusterBean
 * @throws RestAPIException
 */
public static KubernetesClusterBean getKubernetesCluster(String kubernetesClusterId) throws RestAPIException {

    CloudControllerServiceClient cloudControllerServiceClient = getCloudControllerServiceClient();
    if (cloudControllerServiceClient != null) {
        try {
            org.apache.stratos.cloud.controller.stub.domain.kubernetes.KubernetesCluster kubernetesCluster = cloudControllerServiceClient
                    .getKubernetesCluster(kubernetesClusterId);
            return ObjectConverter.convertStubKubernetesClusterToKubernetesCluster(kubernetesCluster);

        } catch (RemoteException e) {
            log.error(e.getMessage(), e);
            throw new RestAPIException(e.getMessage(), e);
        } catch (CloudControllerServiceNonExistingKubernetesClusterExceptionException e) {
            String message = e.getFaultMessage().getNonExistingKubernetesClusterException().getMessage();
            log.error(message);
            throw new RestAPIException(message, e);
        }
    }
    return null;
}

From source file:org.apache.stratos.rest.endpoint.api.StratosApiV41Utils.java

/**
 * Remove Kubernetes Cluster//from w w w.  j a  v a  2 s .  c o  m
 *
 * @param kubernetesClusterId kubernetesClusterId
 * @return remove status
 * @throws RestAPIException
 */
public static boolean removeKubernetesCluster(String kubernetesClusterId)
        throws RestAPIException, CloudControllerServiceNonExistingKubernetesClusterExceptionException,
        CloudControllerServiceKubernetesClusterAlreadyUsedExceptionException {

    CloudControllerServiceClient cloudControllerServiceClient = getCloudControllerServiceClient();
    if (cloudControllerServiceClient != null) {
        try {
            cloudControllerServiceClient.undeployKubernetesCluster(kubernetesClusterId);
            return true;
        } catch (RemoteException e) {
            log.error(e.getMessage(), e);
            throw new RestAPIException(e.getMessage(), e);
        }
    }
    return false;
}

From source file:org.apache.stratos.rest.endpoint.api.StratosApiV41Utils.java

/**
 * Remove Kubernetes Host//from ww  w.  ja v  a  2 s . c o m
 *
 * @param kubernetesHostId Kubernetes HostId
 * @return remove status
 * @throws RestAPIException
 */
public static boolean removeKubernetesHost(String kubernetesHostId) throws RestAPIException {

    CloudControllerServiceClient cloudControllerServiceClient = getCloudControllerServiceClient();
    if (cloudControllerServiceClient != null) {
        try {
            return cloudControllerServiceClient.undeployKubernetesHost(kubernetesHostId);
        } catch (RemoteException e) {
            log.error(e.getMessage(), e);
            throw new RestAPIException(e.getMessage(), e);
        } catch (CloudControllerServiceNonExistingKubernetesHostExceptionException e) {
            String message = e.getFaultMessage().getNonExistingKubernetesHostException().getMessage();
            log.error(message, e);
            throw new RestAPIException(message, e);
        }
    }
    return false;
}

From source file:org.apache.stratos.rest.endpoint.api.StratosApiV41Utils.java

/**
 * Get Kubernetes Hosts/*from ww  w.j ava2s . co m*/
 *
 * @param kubernetesClusterId kubernetesClusterId
 * @return List of KubernetesHostBeans
 * @throws RestAPIException
 */
public static KubernetesHostBean[] getKubernetesHosts(String kubernetesClusterId) throws RestAPIException {

    CloudControllerServiceClient cloudControllerServiceClient = getCloudControllerServiceClient();
    if (cloudControllerServiceClient != null) {
        try {
            org.apache.stratos.cloud.controller.stub.domain.kubernetes.KubernetesHost[] kubernetesHosts = cloudControllerServiceClient
                    .getKubernetesHosts(kubernetesClusterId);

            List<KubernetesHostBean> arrayList = ObjectConverter
                    .convertStubKubernetesHostsToKubernetesHosts(kubernetesHosts);
            KubernetesHostBean[] array = new KubernetesHostBean[arrayList.size()];
            array = arrayList.toArray(array);
            return array;
        } catch (RemoteException e) {
            log.error(e.getMessage(), e);
            throw new RestAPIException(e.getMessage(), e);
        } catch (CloudControllerServiceNonExistingKubernetesClusterExceptionException e) {
            String message = e.getFaultMessage().getNonExistingKubernetesClusterException().getMessage();
            log.error(message);
            throw new RestAPIException(message, e);
        }
    }
    return null;
}