@Override public void commitInsertTable(Table table, boolean overwrite) throws MetaException { LOG.debug("commit insert into table {} overwrite {}", table.getTableName(), overwrite); try { // Check if there segments to load final Path segmentDescriptorDir = getSegmentDescriptorDir(); final List<DataSegment> segmentsToLoad = fetchSegmentsMetadata(segmentDescriptorDir); final String dataSourceName = table.getParameters().get(Constants.DRUID_DATA_SOURCE); //No segments to load still need to honer overwrite if (segmentsToLoad.isEmpty() && overwrite) { //disable datasource //Case it is an insert overwrite we have to disable the existing Druid DataSource DruidStorageHandlerUtils.disableDataSource(getConnector(), getDruidMetadataStorageTablesConfig(), dataSourceName); } else if (!segmentsToLoad.isEmpty()) { // at this point we have Druid segments from reducers but we need to atomically // rename and commit to metadata // Moving Druid segments and committing to druid metadata as one transaction. checkLoadStatus(loadAndCommitDruidSegments(table, overwrite, segmentsToLoad)); } } catch (IOException e) { throw new MetaException(e.getMessage()); } catch (CallbackFailedException c) { LOG.error("Error while committing transaction to druid metadata storage", c); throw new MetaException(c.getCause().getMessage()); } finally { cleanWorkingDir(); } }
public Object invoke(HandleDing h, Object target, Object[] args, MethodProxy mp) { final Handle handle = h.getHandle(); final HandleCallback<?> callback = (HandleCallback<?>) args[0]; try { return callback.withHandle(handle); } catch (Exception e) { throw new CallbackFailedException(e); } } }
@Override public Object invoke(HandleDing h, Object target, Object[] args, MethodProxy mp) { final Handle handle = h.getHandle(); final HandleCallback<?> callback = (HandleCallback<?>) args[0]; try { return callback.withHandle(handle); } catch (Exception e) { throw new CallbackFailedException(e); } } }
private <T> T performCallback(final HandleCallback<T> callback) { if (transactionHandle != null) { try { return callback.withHandle(transactionHandle); } catch (Exception e) { throw new CallbackFailedException(e); } } else { return migratoryContext.getDBI().withHandle(callback); } }
/** * A convenience function which manages the lifecycle of a handle and yields it to a callback * for use by clients. * * @param callback A callback which will receive an open Handle * * @return the value returned by callback * * @throws CallbackFailedException Will be thrown if callback raises an exception. This exception will * wrap the exception thrown by the callback. */ public <ReturnType> ReturnType withHandle(HandleCallback<ReturnType> callback) throws CallbackFailedException { final Handle h = this.open(); try { return callback.withHandle(h); } catch (Exception e) { throw new CallbackFailedException(e); } finally { h.close(); } }
/** * A convenience function which manages the lifecycle of a handle and yields it to a callback * for use by clients. * * @param callback A callback which will receive an open Handle * * @return the value returned by callback * * @throws CallbackFailedException Will be thrown if callback raises an exception. This exception will * wrap the exception thrown by the callback. */ @Override public <ReturnType> ReturnType withHandle(HandleCallback<ReturnType> callback) throws CallbackFailedException { final Handle h = this.open(); try { return callback.withHandle(h); } catch (Exception e) { throw new CallbackFailedException(e); } finally { h.close(); } }