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();
}
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);
}
}
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);
}
}
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;
}
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);
}
}
Aggregations