/** * As Google Drive extractor needs file system helper, it invokes to initialize file system helper. * {@inheritDoc} * @see org.apache.gobblin.source.Source#getExtractor(org.apache.gobblin.configuration.WorkUnitState) */ @Override public Extractor<S, D> getExtractor(WorkUnitState state) throws IOException { Preconditions.checkNotNull(state, "WorkUnitState should not be null"); LOG.info("WorkUnitState from getExtractor: " + state); try { //GoogleDriveExtractor needs GoogleDriveFsHelper initFileSystemHelper(state); } catch (FileBasedHelperException e) { throw new IOException(e); } Preconditions.checkNotNull(fsHelper, "File system helper should not be null"); return new GoogleDriveExtractor<>(state, fsHelper); }
/** * Initialize file system helper at most once for this instance. * {@inheritDoc} * @see org.apache.gobblin.source.extractor.filebased.FileBasedSource#initFileSystemHelper(org.apache.gobblin.configuration.State) */ @Override public synchronized void initFileSystemHelper(State state) throws FileBasedHelperException { if (fsHelper == null) { Credential credential = new GoogleCommon.CredentialBuilder(state.getProp(SOURCE_CONN_PRIVATE_KEY), state.getPropAsList(API_SCOPES)) .fileSystemUri(state.getProp(PRIVATE_KEY_FILESYSTEM_URI)) .proxyUrl(state.getProp(SOURCE_CONN_USE_PROXY_URL)) .port(state.getProp(SOURCE_CONN_USE_PROXY_PORT)) .serviceAccountId(state.getProp(SOURCE_CONN_USERNAME)) .build(); Drive driveClient = new Drive.Builder(credential.getTransport(), GoogleCommon.getJsonFactory(), credential) .setApplicationName(Preconditions.checkNotNull(state.getProp(APPLICATION_NAME), "ApplicationName is required")) .build(); this.fsHelper = closer.register(new GoogleDriveFsHelper(state, driveClient)); } }
/** * Sets a number of the project. */ Builder setNumber(BigInteger number) { this.number = checkNotNull(number); return this; }
/** * Sets a number of the project. */ Builder number(BigInteger number) { this.number = checkNotNull(number); return this; }
/** * Sets an id of the project. */ Builder setId(String id) { this.id = checkNotNull(id); return this; }
/** * Sets quotas assigned to the project. */ Builder setQuota(Quota quota) { this.quota = checkNotNull(quota); return this; }
/** * Sets quotas assigned to the project. */ Builder quota(Quota quota) { this.quota = checkNotNull(quota); return this; }
/** * Sets an id of the project. */ Builder id(String id) { this.id = checkNotNull(id); return this; }
TrackingEventBuilder(SendsEvents eventSender, String category, String action) { this.eventSender = Preconditions.checkNotNull(eventSender); this.category = Preconditions.checkNotNull(category); this.action = Preconditions.checkNotNull(action); }
public WatchableObject(T object) { this.object = Preconditions.checkNotNull(object); }
@Override public FluentTrackingEventWithMetadata addMetadata(String key, String value) { metadataMap.put(Preconditions.checkNotNull(key), Preconditions.checkNotNull(value)); return this; }
protected UpgradeTask(String description, List<String> dependencies) { this.description = Preconditions.checkNotNull(description); this.taskName = getClass().getSimpleName(); this.dependencies.addAll(dependencies); }
@Inject public ThreadPoolTaskRunner( TaskToolboxFactory toolboxFactory ) { this.toolboxFactory = Preconditions.checkNotNull(toolboxFactory, "toolboxFactory"); this.exec = MoreExecutors.listeningDecorator(Execs.singleThreaded("task-runner-%d")); }
/** * As Google Drive extractor needs file system helper, it invokes to initialize file system helper. * {@inheritDoc} * @see org.apache.gobblin.source.Source#getExtractor(org.apache.gobblin.configuration.WorkUnitState) */ @Override public Extractor<S, D> getExtractor(WorkUnitState state) throws IOException { Preconditions.checkNotNull(state, "WorkUnitState should not be null"); LOG.info("WorkUnitState from getExtractor: " + state); try { //GoogleDriveExtractor needs GoogleDriveFsHelper initFileSystemHelper(state); } catch (FileBasedHelperException e) { throw new IOException(e); } Preconditions.checkNotNull(fsHelper, "File system helper should not be null"); return new GoogleDriveExtractor<>(state, fsHelper); }
@LifecycleStart public void start() final File taskFile = Preconditions.checkNotNull(config.getTaskFile(), "taskFile"); final File statusFile = Preconditions.checkNotNull(config.getStatusFile(), "statusFile"); final InputStream parentStream = Preconditions.checkNotNull(config.getParentStream(), "parentStream");
/** * @see SwapJob#evict(String) for high-level description. * * 1. Acquires the project lock. * 2. Gets a bz2 stream and size of a project from the repo store, or throws * 3. Uploads the bz2 stream and size to the projName in the swapStore. * 4. Sets the last accessed time in the dbStore to null, which makes our * state SWAPPED * 5. Removes the project from the repo store. * @param projName * @throws IOException */ @Override public void evict(String projName) throws IOException { Preconditions.checkNotNull(projName, "projName was null"); Log.info("Evicting project: {}", projName); try (LockGuard __ = lock.lockGuard(projName)) { long[] sizePtr = new long[1]; try (InputStream blob = repoStore.bzip2Project(projName, sizePtr)) { swapStore.upload(projName, blob, sizePtr[0]); dbStore.setLastAccessedTime(projName, null); repoStore.remove(projName); } } Log.info("Evicted project: {}", projName); }
/** * Initialize file system helper at most once for this instance. * {@inheritDoc} * @see org.apache.gobblin.source.extractor.filebased.FileBasedSource#initFileSystemHelper(org.apache.gobblin.configuration.State) */ @Override public synchronized void initFileSystemHelper(State state) throws FileBasedHelperException { if (fsHelper == null) { Credential credential = new GoogleCommon.CredentialBuilder(state.getProp(SOURCE_CONN_PRIVATE_KEY), state.getPropAsList(API_SCOPES)) .fileSystemUri(state.getProp(PRIVATE_KEY_FILESYSTEM_URI)) .proxyUrl(state.getProp(SOURCE_CONN_USE_PROXY_URL)) .port(state.getProp(SOURCE_CONN_USE_PROXY_PORT)) .serviceAccountId(state.getProp(SOURCE_CONN_USERNAME)) .build(); Drive driveClient = new Drive.Builder(credential.getTransport(), GoogleCommon.getJsonFactory(), credential) .setApplicationName(Preconditions.checkNotNull(state.getProp(APPLICATION_NAME), "ApplicationName is required")) .build(); this.fsHelper = closer.register(new GoogleDriveFsHelper(state, driveClient)); } }