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.netflix.edda.EddaAwsClient.java
protected byte[] doGet(final String uri) { try {/*from www . j a va 2s. co m*/ return EddaContext.getContext().getRxHttp().get(mkUrl(uri)).flatMap(response -> { if (response.getStatus().code() != 200) { AmazonServiceException e = new AmazonServiceException("Failed to fetch " + uri); e.setStatusCode(response.getStatus().code()); e.setErrorCode("Edda"); e.setRequestId(uri); return rx.Observable.error(e); } return response.getContent().reduce(new ByteArrayOutputStream(), (out, bb) -> { try { bb.readBytes(out, bb.readableBytes()); } catch (IOException e) { throw new RuntimeException(e); } return out; }).map(out -> { return out.toByteArray(); }); }).toBlocking().toFuture().get(2, TimeUnit.MINUTES); } catch (Exception e) { throw new RuntimeException("failed to get url: " + uri, e); } }
From source file:kidozen.client.crash.HttpSender.java
@Override public void send(CrashReportData report) throws ReportSenderException { try {/*from w w w .j av a2s. co m*/ final CountDownLatch cdl = new CountDownLatch(1); IdentityManager.getInstance().GetRawToken(mApplicationKey, new ServiceEventListener() { @Override public void onFinish(ServiceEvent e) { mEvent = e; cdl.countDown(); } }); cdl.await(DEFAULT_TIMEOUT, TimeUnit.MINUTES); if (mEvent.Exception != null || mEvent.StatusCode >= HttpStatus.SC_BAD_REQUEST) throw new ReportSenderException(mEvent.Body); mToken = ((KidoZenUser) mEvent.Response).Token; String authHeaderValue = String.format("WRAP access_token=\"%s\"", mToken); Log.d(LOG_TAG, String.format("About to send log to Log V3 service: %s ", mCrashEndpoint)); JSONObject reportAsJson = report.toJSON(); String bc = new JSONArray(mBreadCrumbs).toString(); reportAsJson.put(APPLICATION_BREADCRUMB, bc); Hashtable<String, String> headers = new Hashtable<String, String>(); headers.put(Constants.AUTHORIZATION_HEADER, authHeaderValue); headers.put(Constants.CONTENT_TYPE, Constants.APPLICATION_JSON); headers.put(Constants.ACCEPT, Constants.APPLICATION_JSON); mSniManager = new SNIConnectionManager(mCrashEndpoint, reportAsJson.toString(), headers, null, true); Hashtable<String, String> response = mSniManager.ExecuteHttp(KZHttpMethod.POST); String body = response.get("responseBody"); Integer statusCode = Integer.parseInt(response.get("statusCode")); if (statusCode >= HttpStatus.SC_MULTIPLE_CHOICES) { String exceptionMessage = (body != null ? body : "Unexpected HTTP Status Code: " + statusCode); throw new Exception(exceptionMessage); } } catch (InterruptedException e) { throw new ReportSenderException("Timeout trying to send report to KidoZen services.", e); } catch (ReportSenderException e) { throw e; } catch (Exception e) { throw new ReportSenderException("Error while sending report to KidoZen services.", e); } }
From source file:rmblworx.tools.timey.AlarmTest.java
@Before public final void setUp() { MockitoAnnotations.initMocks(this); this.effectiveDelegate = new Alarm(this.service, 1, TimeUnit.MINUTES); this.descriptor.getAlarmtime().setMilliSeconds(EXPECTED_MILLISECONDS); this.list = this.createListWithDescriptors(); }
From source file:com.thinkbiganalytics.jira.JiraJerseyClient.java
public JiraJerseyClient(JiraRestClientConfig config) { super(config); this.apiPath = config.getApiPath(); // cache the Issue Types related to a project since they will not change much. // But if they do, expire the cache after a certain amount of time this.issueTypeNameCache = CacheBuilder.newBuilder().expireAfterAccess(20, TimeUnit.MINUTES) .build(new CacheLoader<String, List<String>>() { public List<String> load(String key) { try { return loadIssueTypeNamesForProject(key); } catch (JiraException e) { return null; }// w ww.ja v a2s .c o m } }); //regiser the JoadTime mapper if (client != null) { client.register(JodaTimeMapperProvider.class); } }
From source file:com.cemso.util.CheckDeviceStateExcuter.java
public static void checkStart() { if (log.isDebugEnabled()) { log.debug("CheckDeviceStateExcuter.checkStart()..."); }// w w w . j av a2 s . c o m CheckRunner checker = new CheckDeviceStateExcuter().new CheckRunner(); Thread t = new Thread(checker, "checker"); checkerThread = t; final ScheduledFuture<?> checkerHandle = scheduler.scheduleAtFixedRate(t, 1, 2, TimeUnit.MINUTES); checkerHandle1 = checkerHandle; if (log.isInfoEnabled()) { log.info("auto refresh is started..."); try { File f = new File("C:/DLLfunctionsTest.txt"); FileWriter fw = new FileWriter(f, true); BufferedWriter bw = new BufferedWriter(fw); bw.newLine(); bw.append(new java.util.Date().toString() + ": auto refresh is started..."); bw.newLine(); bw.flush(); bw.close(); } catch (IOException e) { e.printStackTrace(); } } }
From source file:rk.java.compute.cep.EventBusTest.java
@Test public void processOnThreadPerSymbolBasis() throws Exception { ComputeService dispatcher = new ComputeService(numberOfMarketSourceInstances, priceEventSink); dispatcher.subscribeToTickEventsFrom(eventBus); for (int i = 0; i < numberOfMarketSourceInstances; i++) { TradeFeed market = new TradeFeed(numberOfTicksPerProducer); market.setName("Market Maker " + i); market.publishTickEventsTo(eventBus); market.setDaemon(true);// w ww . j ava 2s . c o m market.start(); } StopWatch await = dispatcher.shutDownAndAwaitTermination(1, TimeUnit.MINUTES); System.out.println(await.prettyPrint()); System.out.println(dispatcher); /* * Rem to add for poison pills when counting... */ assertEquals(numberOfMarketSourceInstances * numberOfTicksPerProducer + numberOfMarketSourceInstances, dispatcher.getTicksReceivedCount()); assertEquals(numberOfMarketSourceInstances * numberOfTicksPerProducer + numberOfMarketSourceInstances, dispatcher.getTicksProcessedCount()); }
From source file:net.seedboxer.sources.filter.FilterManager.java
@PostConstruct public void init() { cache = CacheBuilder.newBuilder().maximumSize(500).expireAfterWrite(cacheTimeToLive, TimeUnit.MINUTES) .build(); }
From source file:spring.travel.site.Application.java
@Bean public Cache<String, List<NewsItem>> newsCache() { return CacheBuilder.newBuilder().expireAfterWrite(60, TimeUnit.MINUTES).build(); }
From source file:com.streamsets.pipeline.stage.destination.hdfs.writer.DefaultFsHelper.java
DefaultFsHelper(Stage.Context context, String uniquePrefix, ConcurrentLinkedQueue<Path> closedPaths, RecordWriterManager recordWriterManager) { this.recordWriterManager = recordWriterManager; this.context = context; this.uniquePrefix = uniquePrefix; tempFilePath = new Path(recordWriterManager.getTempFileName()); this.closedPaths = closedPaths; dirPathCache = CacheBuilder.newBuilder().expireAfterAccess(1, TimeUnit.MINUTES) .build(new CacheLoader<String, Path>() { @Override/*from ww w . j ava2 s . c o m*/ public Path load(String key) throws Exception { return new Path(key, tempFilePath); } }); }
From source file:de.matzefratze123.heavyspleef.core.uuid.UUIDManager.java
public UUIDManager() { // Use fast Entity#getUniqueId() when onlineMode = true // so we don't have to query the mojang servers this.onlineMode = Bukkit.getOnlineMode(); this.profileNameCache = CacheBuilder.newBuilder().expireAfterAccess(30, TimeUnit.MINUTES) .build(new CacheLoader<String, GameProfile>() { @SuppressWarnings("deprecation") @Override// w ww. ja v a 2 s . c o m public GameProfile load(String key) throws Exception { GameProfile profile; List<GameProfile> profiles = fetchGameProfiles(new String[] { key }); if (profiles.size() != 0) { profile = profiles.get(0); } else { OfflinePlayer player = Bukkit.getOfflinePlayer(key); profile = new GameProfile(player.getUniqueId(), player.getName()); } validateContain(profile); return profile; } private void validateContain(GameProfile profile) { Map<UUID, GameProfile> map = profileUUIDCache.asMap(); if (!map.containsKey(profile.getUniqueIdentifier())) { profileUUIDCache.put(profile.getUniqueIdentifier(), profile); } } }); this.profileUUIDCache = CacheBuilder.newBuilder().expireAfterAccess(30, TimeUnit.MINUTES) .build(new CacheLoader<UUID, GameProfile>() { @Override public GameProfile load(UUID key) throws Exception { GameProfile profile = fetchGameProfile(key); if (profile == null) { OfflinePlayer player = Bukkit.getServer().getOfflinePlayer(key); profile = new GameProfile(player.getUniqueId(), player.getName()); } validateContain(profile); return profile; } private void validateContain(GameProfile profile) { Map<String, GameProfile> map = profileNameCache.asMap(); if (!map.containsKey(profile.getUniqueIdentifier())) { profileUUIDCache.put(profile.getUniqueIdentifier(), profile); } } }); }