public synchronized File getProjectDirectory() { checkState(state == State.STARTED); return projectDirectory; }
public synchronized File getProjectDirectory() { checkState(state == State.STARTED); return projectDirectory; }
static DateTime queryReplication(Connection connection, String query) throws SQLException { final ResultSet resultSet = connection.createStatement().executeQuery(query); Preconditions.checkState(resultSet.next(), "Replication query returned empty results"); DateTime lastReplication = new DateTime(resultSet.getTimestamp("last_replication")); Duration replicationDelay = new Duration(resultSet.getLong("replication_delay")); LOGGER.info("Psql replication check lastReplication={} replicationDelay={}", lastReplication, replicationDelay); return lastReplication; }
@Override public Builder setScopes(Collection<String> scopes) { Preconditions.checkState(!scopes.isEmpty()); return (Builder) super.setScopes(scopes); }
public static GraphResult fromString(String tsv) { Preconditions.checkNotNull(tsv); String[] tokens = tsv.split("[\\s\t]+"); Preconditions.checkState(3 == tokens.length, "Expected three values in serialized GraphResult but found %d", tokens.length); return new GraphResult(tokens[0], Double.parseDouble(tokens[1]), Double.parseDouble(tokens[2])); }
public static GraphResult fromString(String tsv) { Preconditions.checkNotNull(tsv); String[] tokens = tsv.split("[\\s\t]+"); Preconditions.checkState(3 == tokens.length, "Expected three values in serialized GraphResult but found %d", tokens.length); return new GraphResult(tokens[0], Double.parseDouble(tokens[1]), Double.parseDouble(tokens[2])); }
/** * Constructor with all parameters allowing custom transport and server URL. * * @param clientId Client ID of the credential from the console. * @param clientSecret Client ID of the credential from the console. * @param refreshToken A refresh token resulting from a OAuth2 consent flow. * @param accessToken Initial or temporary access token. * @param transportFactory HTTP transport factory, creates the transport used to get access * tokens. * @param tokenServerUri URI of the end point that provides tokens. * @deprecated Use {@link #newBuilder()} instead. This constructor will either be deleted or made * private in a later version. */ @Deprecated public UserCredentials(String clientId, String clientSecret, String refreshToken, AccessToken accessToken, HttpTransportFactory transportFactory, URI tokenServerUri) { super(accessToken); this.clientId = Preconditions.checkNotNull(clientId); this.clientSecret = Preconditions.checkNotNull(clientSecret); this.refreshToken = refreshToken; this.transportFactory = firstNonNull(transportFactory, getFromServiceLoader(HttpTransportFactory.class, OAuth2Utils.HTTP_TRANSPORT_FACTORY)); this.tokenServerUri = (tokenServerUri == null) ? OAuth2Utils.TOKEN_SERVER_URI : tokenServerUri; this.transportFactoryClassName = this.transportFactory.getClass().getName(); Preconditions.checkState(accessToken != null || refreshToken != null, "Either accessToken or refreshToken must not be null"); }
/** * Constructor with all parameters allowing custom transport and server URL. * * @param clientId Client ID of the credential from the console. * @param clientSecret Client ID of the credential from the console. * @param refreshToken A refresh token resulting from a OAuth2 consent flow. * @param accessToken Initial or temporary access token. * @param transportFactory HTTP transport factory, creates the transport used to get access * tokens. * @param tokenServerUri URI of the end point that provides tokens. * @deprecated Use {@link #newBuilder()} instead. This constructor will either be deleted or made * private in a later version. */ @Deprecated public UserCredentials(String clientId, String clientSecret, String refreshToken, AccessToken accessToken, HttpTransportFactory transportFactory, URI tokenServerUri) { super(accessToken); this.clientId = Preconditions.checkNotNull(clientId); this.clientSecret = Preconditions.checkNotNull(clientSecret); this.refreshToken = refreshToken; this.transportFactory = firstNonNull(transportFactory, getFromServiceLoader(HttpTransportFactory.class, OAuth2Utils.HTTP_TRANSPORT_FACTORY)); this.tokenServerUri = (tokenServerUri == null) ? OAuth2Utils.TOKEN_SERVER_URI : tokenServerUri; this.transportFactoryClassName = this.transportFactory.getClass().getName(); Preconditions.checkState(accessToken != null || refreshToken != null, "Either accessToken or refreshToken must not be null"); }
/** * Return the user id for the currently logged in user. */ static final String getUserId() { UserService userService = UserServiceFactory.getUserService(); User loggedIn = userService.getCurrentUser(); Preconditions.checkState(loggedIn != null, "This servlet requires the user to be logged in."); return loggedIn.getUserId(); } }
/** * Starts the emulator. It is the caller's responsibility to call {@link #stop}. Note that * receiving an exception does not indicate that the server did not start. We recommend calling * {@link #stop} to ensure the server is not running regardless of the result of this method. * * @param emulatorDir The path to the emulator directory, e.g. /usr/local/cloud-datastore-emulator * @param projectId The project ID * @param commandLineOptions Command line options to pass to the emulator on startup * @throws DatastoreEmulatorException If {@link #start} has already been called or the server does * not start successfully. * @deprecated prefer setting options in the emulator options and calling {#start()}. */ @Deprecated public synchronized void start(String emulatorDir, String projectId, String... commandLineOptions) throws DatastoreEmulatorException { checkNotNull(emulatorDir, "emulatorDir cannot be null"); checkNotNull(projectId, "projectId cannot be null"); checkState(state == State.NEW, "Cannot call start() more than once."); try { startEmulatorInternal( emulatorDir + "/cloud_datastore_emulator", projectId, Arrays.asList(commandLineOptions)); state = State.STARTED; } finally { if (state != State.STARTED) { // If we're not able to start the server we don't want people trying again. Just move it // straight to the STOPPED state. state = State.STOPPED; } } }
/** * Starts the emulator. It is the caller's responsibility to call {@link #stop}. Note that * receiving an exception does not indicate that the server did not start. We recommend calling * {@link #stop} to ensure the server is not running regardless of the result of this method. * * @param emulatorDir The path to the emulator directory, e.g. /usr/local/cloud-datastore-emulator * @param projectId The project ID * @param commandLineOptions Command line options to pass to the emulator on startup * @throws DatastoreEmulatorException If {@link #start} has already been called or the server does * not start successfully. * @deprecated prefer setting options in the emulator options and calling {#start()}. */ @Deprecated public synchronized void start(String emulatorDir, String projectId, String... commandLineOptions) throws DatastoreEmulatorException { checkNotNull(emulatorDir, "emulatorDir cannot be null"); checkNotNull(projectId, "projectId cannot be null"); checkState(state == State.NEW, "Cannot call start() more than once."); try { startEmulatorInternal( emulatorDir + "/cloud_datastore_emulator", projectId, Arrays.asList(commandLineOptions)); state = State.STARTED; } finally { if (state != State.STARTED) { // If we're not able to start the server we don't want people trying again. Just move it // straight to the STOPPED state. state = State.STOPPED; } } }
public synchronized void start() throws DatastoreEmulatorException { checkState(state == State.NEW, "Cannot call start() more than once."); try { startEmulatorInternal(options.getCmd(), options.getProjectId(), options.getCmdLineOptions()); state = State.STARTED; } finally { if (state != State.STARTED) { // If we're not able to start the server we don't want people trying again. Just move it // straight to the STOPPED state. state = State.STOPPED; } } }
public synchronized void start() throws DatastoreEmulatorException { checkState(state == State.NEW, "Cannot call start() more than once."); try { startEmulatorInternal(options.getCmd(), options.getProjectId(), options.getCmdLineOptions()); state = State.STARTED; } finally { if (state != State.STARTED) { // If we're not able to start the server we don't want people trying again. Just move it // straight to the STOPPED state. state = State.STOPPED; } } }
/** * Starts the local datastore. It is the caller's responsibility to call {@link #stop}. Note that * receiving an exception does not indicate that the server did not start. We recommend calling * {@link #stop} to ensure the server is not running regardless of the result of this method. * * @param sdkPath The path to the GCD SDK, eg /usr/local/dev/gcd * @param projectId The GCD project ID * @param cmdLineOptions Command line options to pass to the script that launches the dev server * @throws LocalDevelopmentDatastoreException If {@link #start} has already been called or the * server does not start successfully. */ public synchronized void start(String sdkPath, String projectId, String... cmdLineOptions) throws LocalDevelopmentDatastoreException { Preconditions.checkNotNull(sdkPath, "sdkPath cannot be null"); Preconditions.checkNotNull(projectId, "projectId cannot be null"); Preconditions.checkState(state == State.NEW, "Cannot call start() more than once."); try { startDatastoreInternal(sdkPath, projectId, cmdLineOptions); state = State.STARTED; } finally { if (state != State.STARTED) { // If we're not able to start the server we don't want people trying again. Just move it // straight to the STOPPED state. state = State.STOPPED; } } }
throws XmlPullParserException { int eventType = parser.getEventType(); Preconditions.checkState(eventType == XmlPullParser.START_TAG, "expected start of XML element, but got something else (event type %s)", eventType); int depth = parser.getDepth();
Preconditions.checkState( currentBytesServerReceived >= 0 && currentBytesServerReceived <= currentChunkLength); long copyBytes = currentChunkLength - currentBytesServerReceived; Preconditions.checkState(currentBytesServerReceived == actualSkipValue);
Preconditions.checkState(!requestInfos.isEmpty()); HttpRequest batchRequest = requestFactory.buildPostRequest(this.batchUrl, null);