use of io.cdap.cdap.proto.codec.BasicThrowableCodec in project cdap by caskdata.
the class DefaultPreviewStore method setPreviewStatus.
@Override
public void setPreviewStatus(ApplicationId applicationId, PreviewStatus previewStatus) {
// PreviewStore is a singleton and we have to create gson for each operation since gson is not thread safe.
Gson gson = new GsonBuilder().registerTypeAdapter(BasicThrowable.class, new BasicThrowableCodec()).create();
MDSKey mdsKey = getPreviewRowKeyBuilder(META_ROW_KEY_PREFIX, applicationId).build();
try {
previewTable.putDefaultVersion(mdsKey.getKey(), STATUS, Bytes.toBytes(gson.toJson(previewStatus)));
previewTable.putDefaultVersion(mdsKey.getKey(), APPID, Bytes.toBytes(gson.toJson(applicationId)));
} catch (IOException e) {
throw new RuntimeException(String.format("Failed to put preview status %s for preview %s", previewStatus, applicationId), e);
}
}
use of io.cdap.cdap.proto.codec.BasicThrowableCodec in project cdap by caskdata.
the class DefaultPreviewStore method getPreviewStatus.
@Override
public PreviewStatus getPreviewStatus(ApplicationId applicationId) {
// PreviewStore is a singleton and we have to create gson for each operation since gson is not thread safe.
Gson gson = new GsonBuilder().registerTypeAdapter(BasicThrowable.class, new BasicThrowableCodec()).create();
MDSKey mdsKey = getPreviewRowKeyBuilder(META_ROW_KEY_PREFIX, applicationId).build();
byte[] status = null;
try {
status = previewTable.getDefaultVersion(mdsKey.getKey(), STATUS);
} catch (IOException e) {
throw new RuntimeException(String.format("Failed to get the preview status for preview %s", applicationId), e);
}
if (status != null) {
return gson.fromJson(Bytes.toString(status), PreviewStatus.class);
}
return null;
}
Aggregations