List of usage examples for java.util.concurrent TimeUnit MINUTES
TimeUnit MINUTES
To view the source code for java.util.concurrent TimeUnit MINUTES.
Click Source Link
From source file:com.vmware.photon.controller.deployer.xenon.task.UploadVibTaskService.java
@Override public void handleStart(Operation startOp) { ServiceUtils.logTrace(this, "Handling start operation"); if (!startOp.hasBody()) { startOp.fail(new IllegalArgumentException("Body is required")); return;//from w w w.ja v a2 s . c o m } State initialState = startOp.getBody(State.class); InitializationUtils.initialize(initialState); if (initialState.taskTimeoutMicros == null) { initialState.taskTimeoutMicros = TimeUnit.MINUTES.toMicros(10); } if (initialState.documentExpirationTimeMicros <= 0) { initialState.documentExpirationTimeMicros = ServiceUtils .computeExpirationTime(ServiceUtils.DEFAULT_DOC_EXPIRATION_TIME_MICROS); } try { validateInitialState(initialState); } catch (Throwable t) { ServiceUtils.failOperationAsBadRequest(this, startOp, t); return; } if (initialState.taskTimeoutMicros != 0) { super.toggleOption(ServiceOption.PERIODIC_MAINTENANCE, true); super.setMaintenanceIntervalMicros(initialState.taskTimeoutMicros); } startOp.setBody(initialState).complete(); try { if (ControlFlags.isOperationProcessingDisabled(initialState.taskControlFlags)) { ServiceUtils.logInfo(this, "Skipping start operation processing (disabled)"); } else { notifyWorkQueueService(initialState); } } catch (Throwable t) { failTask(t); } }
From source file:com.kixeye.chassis.support.test.metrics.graphite.MetricsGraphiteConfigurationTest.java
@Test public void testUpdatePublishIntervalUnit() { TimeUnit originalIntervalUnit = metricsGraphiteConfiguration.getReporterLoader().getPublishIntervalUnit(); Assert.assertEquals(originalIntervalUnit, TimeUnit.MINUTES); ConfigurationManager.getConfigInstance().setProperty( removePlaceholder(/*from w w w .ja v a 2 s. co m*/ MetricsGraphiteReporterLoader.METRICS_GRAPHITE_PUBLISH_INTERVAL_UNIT_PROPERTY_NAME), TimeUnit.SECONDS + ""); Assert.assertEquals(TimeUnit.SECONDS, metricsGraphiteConfiguration.getReporterLoader().getPublishIntervalUnit()); ConfigurationManager.getConfigInstance().setProperty( removePlaceholder( MetricsGraphiteReporterLoader.METRICS_GRAPHITE_PUBLISH_INTERVAL_UNIT_PROPERTY_NAME), TimeUnit.MINUTES + ""); }
From source file:drusy.ui.panels.InternetStatePanel.java
private String formatInterval(final long l) { final long hr = TimeUnit.SECONDS.toHours(l); final long min = TimeUnit.SECONDS.toMinutes(l - TimeUnit.HOURS.toSeconds(hr)); final long sec = TimeUnit.SECONDS .toSeconds(l - TimeUnit.HOURS.toSeconds(hr) - TimeUnit.MINUTES.toSeconds(min)); return String.format("%02d hours %02d mins %02d secs", hr, min, sec); }
From source file:com.cloudera.livy.rsc.driver.RSCDriver.java
private void initializeServer() throws Exception { String clientId = livyConf.get(CLIENT_ID); Utils.checkArgument(clientId != null, "No client ID provided."); String secret = livyConf.get(CLIENT_SECRET); Utils.checkArgument(secret != null, "No secret provided."); String launcherAddress = livyConf.get(LAUNCHER_ADDRESS); Utils.checkArgument(launcherAddress != null, "Missing launcher address."); int launcherPort = livyConf.getInt(LAUNCHER_PORT); Utils.checkArgument(launcherPort > 0, "Missing launcher port."); LOG.info("Connecting to: {}:{}", launcherAddress, launcherPort); // We need to unset this configuration since it doesn't really apply for the driver side. // If the driver runs on a multi-homed machine, this can lead to issues where the Livy // server cannot connect to the auto-detected address, but since the driver can run anywhere // on the cluster, it would be tricky to solve that problem in a generic way. livyConf.set(RPC_SERVER_ADDRESS, null); if (livyConf.getBoolean(TEST_STUCK_START_DRIVER)) { // Test flag is turned on so we will just infinite loop here. It should cause // timeout and we should still see yarn application being cleaned up. LOG.info("Infinite looping as test flag TEST_STUCK_START_SESSION is turned on."); while (true) { try { TimeUnit.MINUTES.sleep(10); } catch (InterruptedException e) { LOG.warn("Interrupted during test sleep.", e); }//ww w . j a va 2s . co m } } // Bring up the RpcServer an register the secret provided by the Livy server as a client. LOG.info("Starting RPC server..."); this.server = new RpcServer(livyConf); server.registerClient(clientId, secret, new RpcServer.ClientCallback() { @Override public RpcDispatcher onNewClient(Rpc client) { registerClient(client); return RSCDriver.this; } @Override public void onSaslComplete(Rpc client) { onClientAuthenticated(client); } }); // The RPC library takes care of timing out this. Rpc callbackRpc = Rpc.createClient(livyConf, server.getEventLoopGroup(), launcherAddress, launcherPort, clientId, secret, this).get(); try { callbackRpc.call(new RemoteDriverAddress(server.getAddress(), server.getPort())) .get(livyConf.getTimeAsMs(RPC_CLIENT_HANDSHAKE_TIMEOUT), TimeUnit.MILLISECONDS); } catch (TimeoutException te) { LOG.warn("Timed out sending address to Livy server, shutting down."); throw te; } finally { callbackRpc.close(); } // At this point we install the idle timeout handler, in case the Livy server fails to connect // back. setupIdleTimeout(); }
From source file:com.hpcloud.util.Duration.java
public long toMinutes() { return TimeUnit.MINUTES.convert(length, timeUnit); }
From source file:com.omertron.slackbot.functions.scheduler.AbstractBotTask.java
/** * Convert seconds to Hours, Minutes and Seconds * * @param seconds/*w w w . ja v a 2s.c o m*/ * @return */ protected final String formatSeconds(long seconds) { int day = (int) TimeUnit.SECONDS.toDays(seconds); long hours = TimeUnit.SECONDS.toHours(seconds) - TimeUnit.DAYS.toHours(day); long minute = TimeUnit.SECONDS.toMinutes(seconds) - TimeUnit.DAYS.toMinutes(day) - TimeUnit.HOURS.toMinutes(hours); long second = TimeUnit.SECONDS.toSeconds(seconds) - TimeUnit.DAYS.toSeconds(day) - TimeUnit.HOURS.toSeconds(hours) - TimeUnit.MINUTES.toSeconds(minute); return String.format("%1$dh %2$dm %3$ds", hours, minute, second); }
From source file:com.gooddata.warehouse.WarehouseServiceAT.java
@Test(groups = "warehouse", dependsOnMethods = "createWarehouse") public void addS3Credentials() { s3Credentials = service.addS3Credentials(warehouse, s3Credentials).get(1, TimeUnit.MINUTES); assertThat(s3Credentials, notNullValue()); }
From source file:org.mitre.openid.connect.web.ClientDynamicRegistrationEndpoint.java
/** * Create a new Client, issue a client ID, and create a registration access token. * @param jsonString// ww w . j a v a 2 s.c om * @param m * @param p * @return */ @RequestMapping(method = RequestMethod.POST, consumes = "application/json", produces = "application/json") public String registerNewClient(@RequestBody String jsonString, Model m) { ClientDetailsEntity newClient = ClientDetailsEntityJsonProcessor.parse(jsonString); if (newClient != null) { // it parsed! // // Now do some post-processing consistency checks on it // // clear out any spurious id/secret (clients don't get to pick) newClient.setClientId(null); newClient.setClientSecret(null); // set of scopes that are OK for clients to dynamically register for Set<SystemScope> dynScopes = scopeService.getDynReg(); // scopes that the client is asking for Set<SystemScope> requestedScopes = scopeService.fromStrings(newClient.getScope()); // the scopes that the client can have must be a subset of the dynamically allowed scopes Set<SystemScope> allowedScopes = Sets.intersection(dynScopes, requestedScopes); // if the client didn't ask for any, give them the defaults if (allowedScopes == null || allowedScopes.isEmpty()) { allowedScopes = scopeService.getDefaults(); } newClient.setScope(scopeService.toStrings(allowedScopes)); // set default grant types if needed if (newClient.getGrantTypes() == null || newClient.getGrantTypes().isEmpty()) { if (newClient.getScope().contains("offline_access")) { // client asked for offline access newClient.setGrantTypes(Sets.newHashSet("authorization_code", "refresh_token")); // allow authorization code and refresh token grant types by default } else { newClient.setGrantTypes(Sets.newHashSet("authorization_code")); // allow authorization code grant type by default } } // set default response types if needed // TODO: these aren't checked by SECOAUTH // TODO: the consistency between the response_type and grant_type needs to be checked by the client service, most likely if (newClient.getResponseTypes() == null || newClient.getResponseTypes().isEmpty()) { newClient.setResponseTypes(Sets.newHashSet("code")); // default to allowing only the auth code flow } if (newClient.getTokenEndpointAuthMethod() == null) { newClient.setTokenEndpointAuthMethod(AuthMethod.SECRET_BASIC); } if (newClient.getTokenEndpointAuthMethod() == AuthMethod.SECRET_BASIC || newClient.getTokenEndpointAuthMethod() == AuthMethod.SECRET_JWT || newClient.getTokenEndpointAuthMethod() == AuthMethod.SECRET_POST) { // we need to generate a secret newClient = clientService.generateClientSecret(newClient); } // set some defaults for token timeouts newClient.setAccessTokenValiditySeconds((int) TimeUnit.HOURS.toSeconds(1)); // access tokens good for 1hr newClient.setIdTokenValiditySeconds((int) TimeUnit.MINUTES.toSeconds(10)); // id tokens good for 10min newClient.setRefreshTokenValiditySeconds(null); // refresh tokens good until revoked // this client has been dynamically registered (obviously) newClient.setDynamicallyRegistered(true); // now save it try { ClientDetailsEntity savedClient = clientService.saveNewClient(newClient); // generate the registration access token OAuth2AccessTokenEntity token = connectTokenService.createRegistrationAccessToken(savedClient); tokenService.saveAccessToken(token); // send it all out to the view RegisteredClient registered = new RegisteredClient(savedClient, token.getValue(), config.getIssuer() + "register/" + UriUtils.encodePathSegment(savedClient.getClientId(), "UTF-8")); m.addAttribute("client", registered); m.addAttribute("code", HttpStatus.CREATED); // http 201 return "clientInformationResponseView"; } catch (UnsupportedEncodingException e) { logger.error("Unsupported encoding", e); m.addAttribute("code", HttpStatus.INTERNAL_SERVER_ERROR); return "httpCodeView"; } catch (IllegalArgumentException e) { logger.error("Couldn't save client", e); m.addAttribute("code", HttpStatus.BAD_REQUEST); return "httpCodeView"; } } else { // didn't parse, this is a bad request logger.error("registerNewClient failed; submitted JSON is malformed"); m.addAttribute("code", HttpStatus.BAD_REQUEST); // http 400 return "httpCodeView"; } }
From source file:functionaltests.RestSchedulerJobTaskTest.java
@Test public void testUrlMatrixParamsShouldReplaceJobVariables() throws Exception { File jobFile = new File(RestSchedulerJobTaskTest.class.getResource("config/job_matrix_params.xml").toURI()); String schedulerUrl = getResourceUrl("submit;var=matrix_param_val"); HttpPost httpPost = new HttpPost(schedulerUrl); setSessionHeader(httpPost);/*w w w .j a v a2s. c o m*/ MultipartEntityBuilder multipartEntityBuilder = MultipartEntityBuilder.create().addPart("file", new FileBody(jobFile, ContentType.APPLICATION_XML)); httpPost.setEntity(multipartEntityBuilder.build()); HttpResponse response = executeUriRequest(httpPost); assertHttpStatusOK(response); JSONObject jsonObj = toJsonObject(response); final String jobId = jsonObj.get("id").toString(); assertNotNull(jobId); waitJobState(jobId, JobStatus.FINISHED, TimeUnit.MINUTES.toMillis(1)); }