Search in sources :

Example 51 with JsonProcessingException

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project microservices by pwillhan.

the class App method nativeQuery.

private static void nativeQuery(EntityManager entityManager) {
    entityManager.getTransaction().begin();
    Query nativeQuery = entityManager.createNativeQuery("SELECT * FROM ifinances.finances_user");
    List resultList = nativeQuery.getResultList();
    resultList.forEach(u -> {
        try {
            System.out.println(MAPPER.writeValueAsString(u));
        } catch (JsonProcessingException e) {
            e.printStackTrace();
        }
    });
    entityManager.getTransaction().commit();
}
Also used : Query(javax.persistence.Query) List(java.util.List) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 52 with JsonProcessingException

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project kubernetes by ballerinax.

the class DeploymentHandler method generate.

/**
 * Generate kubernetes deployment definition from annotation.
 *
 * @return Generated kubernetes @{@link Deployment} definition
 * @throws KubernetesPluginException If an error occurs while generating artifact.
 */
public String generate() throws KubernetesPluginException {
    List<ContainerPort> containerPorts = null;
    if (deploymentModel.getPorts() != null) {
        containerPorts = populatePorts(deploymentModel.getPorts());
    }
    Container container = generateContainer(deploymentModel, containerPorts);
    Deployment deployment = new DeploymentBuilder().withNewMetadata().withName(deploymentModel.getName()).withNamespace(deploymentModel.getNamespace()).withLabels(deploymentModel.getLabels()).endMetadata().withNewSpec().withReplicas(deploymentModel.getReplicas()).withNewTemplate().withNewMetadata().addToLabels(deploymentModel.getLabels()).endMetadata().withNewSpec().withContainers(container).withVolumes(populateVolume(deploymentModel)).endSpec().endTemplate().endSpec().build();
    try {
        return SerializationUtils.dumpWithoutRuntimeStateAsYaml(deployment);
    } catch (JsonProcessingException e) {
        String errorMessage = "Error while parsing yaml file for deployment: " + deploymentModel.getName();
        throw new KubernetesPluginException(errorMessage, e);
    }
}
Also used : Container(io.fabric8.kubernetes.api.model.Container) ContainerPort(io.fabric8.kubernetes.api.model.ContainerPort) Deployment(io.fabric8.kubernetes.api.model.extensions.Deployment) KubernetesPluginException(org.ballerinax.kubernetes.exceptions.KubernetesPluginException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) DeploymentBuilder(io.fabric8.kubernetes.api.model.extensions.DeploymentBuilder)

Example 53 with JsonProcessingException

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project kubernetes by ballerinax.

the class PersistentVolumeClaimHandler method generate.

@Override
public String generate() throws KubernetesPluginException {
    Quantity quantity = new QuantityBuilder().withAmount(volumeClaimModel.getVolumeClaimSize()).build();
    Map<String, Quantity> requests = new HashMap<>();
    requests.put("storage", quantity);
    PersistentVolumeClaim secret = new PersistentVolumeClaimBuilder().withNewMetadata().withName(volumeClaimModel.getName()).endMetadata().withNewSpec().withAccessModes(volumeClaimModel.getAccessMode()).withNewResources().withRequests(requests).endResources().endSpec().build();
    try {
        return SerializationUtils.dumpWithoutRuntimeStateAsYaml(secret);
    } catch (JsonProcessingException e) {
        String errorMessage = "Error while parsing yaml file for volume claim: " + volumeClaimModel.getName();
        throw new KubernetesPluginException(errorMessage, e);
    }
}
Also used : QuantityBuilder(io.fabric8.kubernetes.api.model.QuantityBuilder) HashMap(java.util.HashMap) Quantity(io.fabric8.kubernetes.api.model.Quantity) PersistentVolumeClaimBuilder(io.fabric8.kubernetes.api.model.PersistentVolumeClaimBuilder) PersistentVolumeClaim(io.fabric8.kubernetes.api.model.PersistentVolumeClaim) KubernetesPluginException(org.ballerinax.kubernetes.exceptions.KubernetesPluginException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 54 with JsonProcessingException

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project Singularity by HubSpot.

the class SingularityWebhookSender method executeWebhookAsync.

// TODO handle retries, errors.
private <T> CompletableFuture<Response> executeWebhookAsync(SingularityWebhook webhook, Object payload, AbstractSingularityWebhookAsyncHandler<T> handler) {
    LOG.trace("Sending {} to {}", payload, webhook.getUri());
    BoundRequestBuilder postRequest = http.preparePost(webhook.getUri());
    postRequest.setHeader(HttpHeaders.CONTENT_TYPE, "application/json");
    try {
        postRequest.setBody(objectMapper.writeValueAsBytes(payload));
    } catch (JsonProcessingException e) {
        throw Throwables.propagate(e);
    }
    CompletableFuture<Response> webhookFuture = new CompletableFuture<>();
    try {
        handler.setCompletableFuture(webhookFuture);
        postRequest.execute(handler);
    } catch (IOException e) {
        LOG.warn("Couldn't execute webhook to {}", webhook.getUri(), e);
        if (handler.shouldDeleteUpdateDueToQueueAboveCapacity()) {
            handler.deleteWebhookUpdate();
        }
        webhookFuture.completeExceptionally(e);
    }
    return webhookFuture;
}
Also used : Response(com.ning.http.client.Response) BoundRequestBuilder(com.ning.http.client.AsyncHttpClient.BoundRequestBuilder) CompletableFuture(java.util.concurrent.CompletableFuture) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 55 with JsonProcessingException

use of org.apache.flink.shaded.jackson2.com.fasterxml.jackson.core.JsonProcessingException in project data-prep by Talend.

the class SuggestDataSetActions method onExecute.

/**
 * Retrieve the dataset metadata and look for the possible actions.
 *
 * @return the dataset possible actions.
 */
private HttpRequestBase onExecute() {
    try {
        // retrieve dataset metadata
        DataSetMetadata metadata = getInput();
        // queries its possible actions
        final HttpPost post = new HttpPost(transformationServiceUrl + "/suggest/dataset");
        post.setHeader(new BasicHeader("Content-Type", MediaType.APPLICATION_JSON_VALUE));
        byte[] dataSetMetadataJSON = objectMapper.writer().writeValueAsBytes(metadata);
        post.setEntity(new ByteArrayEntity(dataSetMetadataJSON));
        return post;
    } catch (JsonProcessingException e) {
        throw new TDPException(CommonErrorCodes.UNEXPECTED_EXCEPTION, e);
    }
}
Also used : TDPException(org.talend.dataprep.exception.TDPException) HttpPost(org.apache.http.client.methods.HttpPost) ByteArrayEntity(org.apache.http.entity.ByteArrayEntity) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata) BasicHeader(org.apache.http.message.BasicHeader)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)741 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)241 IOException (java.io.IOException)174 HashMap (java.util.HashMap)108 Map (java.util.Map)83 ArrayList (java.util.ArrayList)74 JsonNode (com.fasterxml.jackson.databind.JsonNode)73 Test (org.junit.Test)65 List (java.util.List)56 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)36 Collectors (java.util.stream.Collectors)30 InputStream (java.io.InputStream)26 Json (com.sequenceiq.cloudbreak.domain.json.Json)21 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)20 File (java.io.File)20 Function (java.util.function.Function)20 Logger (org.slf4j.Logger)20 Optional (java.util.Optional)19 Date (java.util.Date)18 Test (org.testng.annotations.Test)18