code
stringlengths
73
34.1k
label
stringclasses
1 value
protected void usage() { String footnotes = null; if (!getOptions().getCommands().isEmpty()) { footnotes = "Use `" + CSLToolContext.current().getToolName() + " help <command>' to read about a specific command."; } String name = CSLToolContext.current().getToolName(); String usageName = getUsageName...
java
public Map<String, Object> parseObject() throws IOException { Type t = lexer.readNextToken(); if (t != Type.START_OBJECT) { throw new IOException("Unexpected token: " + t); } return parseObjectInternal(); }
java
public List<Object> parseArray() throws IOException { Type t = lexer.readNextToken(); if (t != Type.START_ARRAY) { throw new IOException("Unexpected token: " + t); } return parseArrayInternal(); }
java
private Object readValue(Type t) throws IOException { switch (t) { case START_OBJECT: return parseObjectInternal(); case START_ARRAY: return parseArrayInternal(); case STRING: return lexer.readString(); case NUMBER: return lexer.readNumber(); case TRUE: return true; case FALS...
java
public static Result parse(String[] args, Collection<Class<? extends Command>> excluded) throws IntrospectionException, InvalidOptionException { List<Class<? extends Command>> classes = new ArrayList<>(); return getCommandClass(args, 0, classes, new HashSet<>(excluded)); }
java
private static String decodeUrl(String endcodedUrl) { String imageSize = "z"; // [mstzb] String[] parts = endcodedUrl.split("_"); String farmId = parts[0]; String serverId = parts[1]; String identidier = parts[2]; String secret = parts[3]; // String isVideo = parts[4]; String url = "https://fa...
java
public void setFromAddress(final String name, final String fromAddress) { fromRecipient = new Recipient(name, fromAddress, null); }
java
public void submitImageDownloadTask(String URL, String id) { Callable<ImageDownloadResult> call = new ImageDownload(URL, id, downloadFolder, saveThumb, saveOriginal, followRedirects); pool.submit(call); numPendingTasks++; }
java
public void submitHadoopDownloadTask(String URL, String id) { Callable<ImageDownloadResult> call = new HadoopImageDownload(URL, id, followRedirects); pool.submit(call); numPendingTasks++; }
java
public ImageDownloadResult getImageDownloadResult() throws Exception { Future<ImageDownloadResult> future = pool.poll(); if (future == null) { // no completed tasks in the pool return null; } else { try { ImageDownloadResult imdr = future.get(); return imdr; } catch (Exception e) { t...
java
public ImageDownloadResult getImageDownloadResultWait() throws Exception { try { ImageDownloadResult imdr = pool.take().get(); return imdr; } catch (Exception e) { throw e; } finally { // in any case (Exception or not) the numPendingTask should be reduced numPendingTasks--; } }
java
public static void downloadFromUrlsFile(String dowloadFolder, String urlsFile, int numUrls, int urlsToSkip) throws Exception { long start = System.currentTimeMillis(); int numThreads = 10; BufferedReader in = new BufferedReader(new FileReader(new File(urlsFile))); for (int i = 0; i < urlsToSkip; i++) { ...
java
public static void main(String[] args) throws Exception { String dowloadFolder = "images/"; String urlsFile = "urls.txt"; int numUrls = 1000; int urlsToSkip = 0; downloadFromUrlsFile(dowloadFolder, urlsFile, numUrls, urlsToSkip); }
java
protected int computeNearestCentroid(double[] descriptor) { int centroidIndex = -1; double minDistance = Double.MAX_VALUE; for (int i = 0; i < numCentroids; i++) { double distance = 0; for (int j = 0; j < descriptorLength; j++) { distance += (codebook[i][j] - descriptor[j]) * (codebook[i][j] - des...
java
public static String readURLToString(URL u, String encoding) throws IOException { for (int i = 0; i < 30; ++i) { URLConnection conn = u.openConnection(); // handle HTTP URLs if (conn instanceof HttpURLConnection) { HttpURLConnection hconn = (HttpURLConnection)conn; // set timeouts hconn.setConn...
java
public static String readFileToString(File f, String encoding) throws IOException { return readStreamToString(new FileInputStream(f), encoding); }
java
public static String readStreamToString(InputStream is, String encoding) throws IOException { try { StringBuilder sb = new StringBuilder(); byte[] buf = new byte[1024 * 10]; int read; while ((read = is.read(buf)) >= 0) { sb.append(new String(buf, 0, read, encoding)); } return sb.toString(); } ...
java
public static byte[] readStream(InputStream is) throws IOException { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); byte[] buf = new byte[1024 * 10]; int read; while ((read = is.read(buf)) >= 0) { baos.write(buf, 0, read); } return baos.toByteArray(); } finally { is.close()...
java
private static Object toJson(Object obj, JsonBuilderFactory factory) { if (obj instanceof JsonObject) { return ((JsonObject)obj).toJson(factory.createJsonBuilder()); } else if (obj.getClass().isArray()) { List<Object> r = new ArrayList<>(); int len = Array.getLength(obj); for (int i = 0; i < len; ++i) {...
java
protected void indexVectorInternal(double[] vector) throws Exception { if (vector.length != vectorLength) { throw new Exception("The dimensionality of the vector is wrong!"); } // apply a random transformation if needed if (transformation == TransformationType.RandomRotation) { vector = rr.rotate(ve...
java
private BoundedPriorityQueue<Result> computeKnnADC(int k, double[] qVector) { BoundedPriorityQueue<Result> nn = new BoundedPriorityQueue<Result>(new Result(), k); // apply a random transformation if needed if (transformation == TransformationType.RandomRotation) { qVector = rr.rotate(qVector); } else ...
java
private BoundedPriorityQueue<Result> computeKnnSDC(int k, int iid) { BoundedPriorityQueue<Result> nn = new BoundedPriorityQueue<Result>(new Result(), k); // find the product quantization code of the vector with the given id, i.e the centroid indices int[] pqCodeQuery = new int[numSubVectors]; for (int m = 0...
java
protected OAuth createOAuth(String consumerKey, String consumerSecret, String redirectUri) { return new OAuth1(consumerKey, consumerSecret); }
java
private void setSpacing() { final int verticalSpacing = styledAttributes.getDimensionPixelOffset(R.styleable.PinLock_keypadVerticalSpacing, 2); final int horizontalSpacing = styledAttributes.getDimensionPixelOffset(R.styleable.PinLock_keypadHorizontalSpacing, 2); setVerticalSpacing(verticalSpaci...
java
public double[] transformToVector() throws Exception { if (vectorLength > vladAggregator.getVectorLength() || vectorLength <= 0) { throw new Exception("Vector length should be between 1 and " + vladAggregator.getVectorLength()); } // the local features are extracted double[][] features; if (image =...
java
public static void main(String args[]) throws Exception { String imageFolder = "C:/images/"; String imagFilename = "test.jpg"; String[] codebookFiles = { "C:/codebook1.csv", "C:/codebook2.csv", "C:/codebook3.csv", "C:/codebook4.csv" }; int[] numCentroids = { 64, 64, 64, 64 }; String pcaFilename = ...
java
private static CSLItemData[] sanitizeItems(ItemDataProvider provider) { Set<String> knownIds = new LinkedHashSet<>(); //create a date parser which will be used to get the item's year CSLDateParser dateParser = new CSLDateParser(); //iterate through all items String[] ids = provider.getIds(); CSLItemDa...
java
private static String makeId(CSLItemData item, CSLDateParser dateParser) { if (item.getAuthor() == null || item.getAuthor().length == 0) { //there's no author information, return original ID return item.getId(); } //get author's name CSLName firstAuthor = item.getAuthor()[0]; String a = firstAuthor.g...
java
private static String uniquify(String id, Set<String> knownIds) { int n = 10; String olda = id; while (knownIds.contains(id)) { id = olda + Integer.toString(n, Character.MAX_RADIX); ++n; } return id; }
java
public synchronized boolean indexVector(String id, double[] vector) throws Exception { long startIndexing = System.currentTimeMillis(); // check if we can index more vectors if (loadCounter >= maxNumVectors) { System.out.println("Maximum index capacity reached, no more vectors can be indexed!"); return...
java
public int getInternalId(String id) { DatabaseEntry key = new DatabaseEntry(); StringBinding.stringToEntry(id, key); DatabaseEntry data = new DatabaseEntry(); // check if the id already exists in id to iid database if ((idToIidDB.get(null, key, data, null) == OperationStatus.SUCCESS)) { return Intege...
java
public String getId(int iid) { if (iid < 0 || iid > loadCounter) { System.out.println("Internal id " + iid + " is out of range!"); return null; } DatabaseEntry key = new DatabaseEntry(); IntegerBinding.intToEntry(iid, key); DatabaseEntry data = new DatabaseEntry(); if ((iidToIdDB.get(null, key...
java
public boolean setGeolocation(int iid, double latitude, double longitude) { if (iid < 0 || iid > loadCounter) { System.out.println("Internal id " + iid + " is out of range!"); return false; } DatabaseEntry key = new DatabaseEntry(); DatabaseEntry data = new DatabaseEntry(); IntegerBinding.intTo...
java
public boolean setMetadata(int iid, Object metaData) { if (iid < 0 || iid > loadCounter) { System.out.println("Internal id " + iid + " is out of range!"); return false; } MetaDataEntity mde = new MetaDataEntity(iid, metaData); PrimaryIndex<Integer, MetaDataEntity> primaryIndex = iidToMetadataDB.getP...
java
public void dumpidToIidDB(String dumpFilename) throws Exception { DatabaseEntry foundKey = new DatabaseEntry(); DatabaseEntry foundData = new DatabaseEntry(); ForwardCursor cursor = idToIidDB.openCursor(null, null); BufferedWriter out = new BufferedWriter(new FileWriter(new File(dumpFilename))); while ...
java
public void outputIndexingTimes() { System.out.println( (double) totalInternalVectorIndexingTime / loadCounter + " ms => internal indexing time"); System.out.println((double) totalIdMappingTime / loadCounter + " ms => id mapping time"); System.out.println((double) totalVectorIndexingTime / loadCounter + "...
java
public void close() { if (dbEnv != null) { // closing dbs iidToIdDB.close(); idToIidDB.close(); if (useGeolocation) { iidToGeolocationDB.close(); } if (useMetaData) { iidToMetadataDB.close(); } closeInternal(); dbEnv.close(); // closing env } else { System.out.pri...
java
public void savePCAToFile(String PCAFileName) throws Exception { if (isPcaInitialized) { throw new Exception("Cannot save, PCA is initialized!"); } if (V_t == null) { throw new Exception("Cannot save to file, PCA matrix is null!"); } BufferedWriter out = new BufferedWriter(new FileWriter(PCAFileN...
java
public void submitImageVectorizationTask(String imageFolder, String imageName) { Callable<ImageVectorizationResult> call = new ImageVectorization(imageFolder, imageName, targetVectorLength, maxImageSizeInPixels); pool.submit(call); numPendingTasks++; }
java
public ImageVectorizationResult getImageVectorizationResult() throws Exception { Future<ImageVectorizationResult> future = pool.poll(); if (future == null) { return null; } else { try { ImageVectorizationResult imvr = future.get(); return imvr; } catch (Exception e) { throw e; } ...
java
public ImageVectorizationResult getImageVectorizationResultWait() throws Exception { try { ImageVectorizationResult imvr = pool.take().get(); return imvr; } catch (Exception e) { throw e; } finally { // in any case (Exception or not) the numPendingTask should be reduced numPendingTasks--; ...
java
public List<String> getHeaders(String name) { Map<String, List<String>> fields = conn.getHeaderFields(); if (fields == null) { return null; } return fields.get(name); }
java
public double[] aggregate(ArrayList<double[]> descriptors) throws Exception { double[] multiVlad = new double[vectorLength]; int vectorShift = 0; for (int i = 0; i < vladAggregators.length; i++) { double[] subVlad = vladAggregators[i].aggregate(descriptors); if (normalizationsOn) { Normalization.n...
java
public static boolean isValid(final String email, final EmailAddressValidationCriteria emailAddressValidationCriteria) { return buildValidEmailPattern(emailAddressValidationCriteria).matcher(email).matches(); }
java
private List<Object> convertArray(V8Array arr) { List<Object> l = new ArrayList<>(); for (int i = 0; i < arr.length(); ++i) { Object o = arr.get(i); if (o instanceof V8Array) { o = convert((V8Array)o, List.class); } else if (o instanceof V8Object) { o = convert((V8Object)o, Map.class); } l.ad...
java
private Map<String, Object> convertObject(V8Object obj) { if (obj.isUndefined()) { return null; } Map<String, Object> r = new LinkedHashMap<>(); for (String k : obj.getKeys()) { Object o = obj.get(k); if (o instanceof V8Array) { o = convert((V8Array)o, List.class); } else if (o instanceof V8Obje...
java
private V8Array convertArguments(Object[] args, Set<V8Value> newValues) { //create the array V8Array result = new V8Array(runtime); newValues.add(result); //convert the values for (int i = 0; i < args.length; ++i) { Object o = args[i]; if (o == null) { result.push(V8Value.NULL); } else if (o i...
java
private V8Object convertJavaObject(Object o) { V8Object v8o = new V8Object(runtime); Method[] methods = o.getClass().getMethods(); for (Method m : methods) { v8o.registerJavaMethod(o, m.getName(), m.getName(), m.getParameterTypes()); } return v8o; }
java
protected void indexVectorInternal(double[] vector) throws Exception { if (vector.length != vectorLength) { throw new Exception("The dimensionality of the vector is wrong!"); } // append the persistent index appendPersistentIndex(vector); // append the ram-based index if (loadIndexInMemory) { ...
java
protected BoundedPriorityQueue<Result> computeNearestNeighborsInternal(int k, double[] queryVector) throws Exception { BoundedPriorityQueue<Result> nn = new BoundedPriorityQueue<Result>(new Result(), k); double lowest = Double.MAX_VALUE; for (int i = 0; i < (vectorsList.size() / vectorLength); i++) { ...
java
protected BoundedPriorityQueue<Result> computeNearestNeighborsInternal(int k, int iid) throws Exception { double[] queryVector = getVector(iid); // get the vector with this internal id return computeNearestNeighborsInternal(k, queryVector); }
java
private void appendPersistentIndex(double[] vector) { TupleOutput output = new TupleOutput(); for (int i = 0; i < vectorLength; i++) { output.writeDouble(vector[i]); } DatabaseEntry data = new DatabaseEntry(); TupleBinding.outputToEntry(output, data); DatabaseEntry key = new DatabaseEntry(); In...
java
public void toCSV(String fileName) throws Exception { BufferedWriter out = new BufferedWriter(new FileWriter(new File(fileName))); for (int i = 0; i < loadCounter; i++) { String identifier = getId(i); double[] vector = getVector(i); out.write(identifier); for (int k = 0; k < vector.length; k++) { ...
java
public static List<String> getSupportedOutputFormats() throws IOException { ScriptRunner runner = getRunner(); try { return runner.callMethod("getSupportedFormats", List.class); } catch (ScriptRunnerException e) { throw new IllegalStateException("Could not get supported formats", e); } }
java
public static boolean supportsStyle(String style) { String styleFileName = style; if (!styleFileName.endsWith(".csl")) { styleFileName = styleFileName + ".csl"; } if (!styleFileName.startsWith("/")) { styleFileName = "/" + styleFileName; } URL url = CSL.class.getResource(styleFileName); return (url ...
java
public static Set<String> getSupportedLocales() throws IOException { Set<String> locales = getAvailableFiles("locales-", "en-US", "xml"); try { List<String> baseLocales = getRunner().callMethod( "getBaseLocales", List.class); locales.addAll(baseLocales); } catch (ScriptRunnerException e) { //ignore....
java
private boolean isStyle(String style) { for (int i = 0; i < style.length(); ++i) { char c = style.charAt(i); if (!Character.isWhitespace(c)) { return (c == '<'); } } return false; }
java
private boolean isDependent(String style) { if (!style.trim().startsWith("<")) { return false; } Pattern p = Pattern.compile("rel\\s*=\\s*\"\\s*independent-parent\\s*\""); Matcher m = p.matcher(style); return m.find(); }
java
public String getIndependentParentLink(String style) throws ParserConfigurationException, IOException, SAXException { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); InputSource src = new InputSource(new StringReader(style)); Docu...
java
public void setOutputFormat(String format) { try { runner.callMethod(engine, "setOutputFormat", format); outputFormat = format; } catch (ScriptRunnerException e) { throw new IllegalArgumentException("Could not set output format", e); } }
java
public static Bibliography makeAdhocBibliography(String style, String outputFormat, CSLItemData... items) throws IOException { ItemDataProvider provider = new ListItemDataProvider(items); try (CSL csl = new CSL(provider, style)) { csl.setOutputFormat(outputFormat); String[] ids = new String[items.length];...
java
public static String getDidYouMeanString(Collection<String> available, String it) { String message = ""; Collection<String> mins = Levenshtein.findSimilar(available, it); if (mins.size() > 0) { if (mins.size() == 1) { message += "Did you mean this?"; } else { message += "Did you mean one of these...
java
public double[] rotate(double[] vector) { DenseMatrix64F transformed = new DenseMatrix64F(1, vector.length); DenseMatrix64F original = DenseMatrix64F.wrap(1, vector.length, vector); CommonOps.mult(original, randomMatrix, transformed); return transformed.getData(); }
java
public static Throwable getCause(Throwable e) { Throwable cause = null; Throwable result = e; while (null != (cause = result.getCause()) && (result != cause)) { result = cause; } return result; }
java
public static void setupProperties(String propertyAndValue, String separator) { String[] tokens = propertyAndValue.split(separator, 2); if (tokens.length == 2) { String name = MonitoringViewProperties.PARFAIT + "." + tokens[0]; String value = tokens[1]; System.setProp...
java
public static List<Specification> parseAllSpecifications() { List<Specification> allMonitorables = new ArrayList<>(); try { File[] files = new File(PATHNAME).listFiles(); if (files != null) { for (File file : files) { allMonitorables.addAll(par...
java
public static List<Specification> parseSpecification(File file) { List<Specification> monitorables = new ArrayList<>(); try { InputStream stream = new FileInputStream(file); monitorables = parseInputSpecification(stream); } catch (Exception e) { logger.error(S...
java
public void clear() { /** * Unfortunately log4j's MDC historically never had a mechanism to block remove keys, * so we're forced to do this one by one. */ for (String key : allKeys()) { mdcBridge.remove(key); } PER_THREAD_CONTEXTS.getUnchecked(Thre...
java
public Map<String, Object> forThread(Thread t) { return new HashMap<String, Object>(PER_THREAD_CONTEXTS.getUnchecked(t)); }
java
@SuppressWarnings("unchecked") public synchronized <T> T registerOrReuse(Monitorable<T> monitorable) { String name = monitorable.getName(); if (monitorables.containsKey(name)) { Monitorable<?> existingMonitorableWithSameName = monitorables.get(name); if (monitorable.getS...
java
@GuardedBy("lock") private void cleanState() { long eventTime = timeSource.get(); long bucketsToSkip = (eventTime - headTime) / window.getResolution(); while (bucketsToSkip > 0) { headIndex = (headIndex + 1) % interimValues.length; bucketsToSkip--; overallValue -= interimValues[headIndex]; interimVal...
java
private void writeToc(ByteBuffer dataFileBuffer, TocType tocType, int entryCount, int firstEntryOffset) { dataFileBuffer.putInt(tocType.identifier); dataFileBuffer.putInt(entryCount); dataFileBuffer.putLong(firstEntryOffset); }
java
public static TimeWindow of(int resolution, long period, String name) { return new TimeWindow(resolution, period, name); }
java
public Set<Library> getMissingLibraries(MinecraftDirectory minecraftDir) { Set<Library> missing = new LinkedHashSet<>(); for (Library library : libraries) if (library.isMissing(minecraftDir)) missing.add(library); return Collections.unmodifiableSet(missing); }
java
public synchronized void refreshWithToken(String clientToken, String accessToken) throws AuthenticationException { authResult = authenticationService.refresh(Objects.requireNonNull(clientToken), Objects.requireNonNull(accessToken)); }
java
public BigDecimal getBigDecimal(int index) throws JSONException { Object object = this.get(index); try { return new BigDecimal(object.toString()); } catch (Exception e) { throw new JSONException("JSONArray[" + index + "] could not convert to BigDecimal."); } }
java
public BigDecimal optBigDecimal(int index, BigDecimal defaultValue) { try { return this.getBigDecimal(index); } catch (Exception e) { return defaultValue; } }
java
public static Version resolveVersion(MinecraftDirectory minecraftDir, String version) throws IOException { Objects.requireNonNull(minecraftDir); Objects.requireNonNull(version); if (doesVersionExist(minecraftDir, version)) { try { return getVersionParser().parseVersion(resolveVersionHierarchy(version, min...
java
public BigDecimal getBigDecimal(String key) throws JSONException { Object object = this.get(key); try { return new BigDecimal(object.toString()); } catch (Exception e) { throw new JSONException("JSONObject[" + quote(key) + "] could not be converted to BigDecimal."); } }
java
public BigDecimal optBigDecimal(String key, BigDecimal defaultValue) { try { return this.getBigDecimal(key); } catch (Exception e) { return defaultValue; } }
java
public static <T> CombinedDownloadTask<T> single(DownloadTask<T> task) { Objects.requireNonNull(task); return new SingleCombinedTask<T>(task); }
java
public static String createRandomAlphanumeric(final int length) { final Random r = ThreadLocalRandom.current(); final char[] randomChars = new char[length]; for (int i = 0; i < length; ++i) { randomChars[i] = ALPHANUMERICS[r.nextInt(ALPHANUMERICS.length)]; } return new String(randomChars); }
java
public static void generateInvocationIdIfNecessary(final TraceeBackend backend) { if (backend != null && !backend.containsKey(TraceeConstants.INVOCATION_ID_KEY) && backend.getConfiguration().shouldGenerateInvocationId()) { backend.put(TraceeConstants.INVOCATION_ID_KEY, Utilities.createRandomAlphanumeric(backend.ge...
java
public static void generateSessionIdIfNecessary(final TraceeBackend backend, final String sessionId) { if (backend != null && !backend.containsKey(TraceeConstants.SESSION_ID_KEY) && backend.getConfiguration().shouldGenerateSessionId()) { backend.put(TraceeConstants.SESSION_ID_KEY, Utilities.createAlphanumericHash(...
java
@Override public Service get() { String serviceName = this.environment.getVariable(SERVICE_NAME_KEY); if (Strings.isNullOrEmpty(serviceName)) { String errorMessage = String.format("Environment variable '%s' is not set", SERVICE_NAME_KEY); throw new IllegalArgumentException(errorMessage);...
java
public static ResourceName create(PathTemplate template, String path) { ImmutableMap<String, String> values = template.match(path); if (values == null) { throw new ValidationException("path '%s' does not match template '%s'", path, template); } return new ResourceName(template, values, null); }
java
public static ResourceName create(PathTemplate template, Map<String, String> values) { if (!values.keySet().containsAll(template.vars())) { Set<String> unbound = Sets.newLinkedHashSet(template.vars()); unbound.removeAll(values.keySet()); throw new ValidationException("unbound variables: %s", unbou...
java
@Nullable public static ResourceName createFromFullName(PathTemplate template, String path) { ImmutableMap<String, String> values = template.matchFromFullName(path); if (values == null) { return null; } return new ResourceName(template, values, null); }
java
public ResourceName withEndpoint(String endpoint) { return new ResourceName(template, values, Preconditions.checkNotNull(endpoint)); }
java
static ImmutableMap<String, TypeDescriptor> verifyAndSort(Map<String, TypeDescriptor> typesByAlias) { List<String> sorted = new ArrayList<>(); for (Map.Entry<String, TypeDescriptor> entry : typesByAlias.entrySet()) { String alias = entry.getKey(); TypeDescriptor type = entry.getV...
java
public static Distribution addSample(double value, Distribution distribution) { Builder builder = distribution.toBuilder(); switch (distribution.getBucketOptionCase()) { case EXPLICIT_BUCKETS: updateStatistics(value, builder); updateExplicitBuckets(value, builder); return builder.b...
java
public synchronized void start() { if (running) { log.atInfo().log("%s is already started", this); return; } log.atInfo().log("starting %s", this); this.stopped = false; this.running = true; this.reportStopwatch.reset().start(); try { schedulerThread = threads.newThread(new...
java
public void stop() { Preconditions.checkState(running, "Cannot stop if it's not running"); synchronized (this) { log.atInfo().log("stopping client background thread and flushing the report aggregator"); for (ReportRequest req : reportAggregator.clear()) { try { transport.services(...
java
public @Nullable CheckResponse check(CheckRequest req) { startIfStopped(); statistics.totalChecks.incrementAndGet(); Stopwatch w = Stopwatch.createStarted(ticker); CheckResponse resp = checkAggregator.check(req); statistics.totalCheckCacheLookupTimeMillis.addAndGet(w.elapsed(TimeUnit.MILLISECONDS));...
java
public void report(ReportRequest req) { startIfStopped(); statistics.totalReports.incrementAndGet(); statistics.reportedOperations.addAndGet(req.getOperationsCount()); Stopwatch w = Stopwatch.createStarted(ticker); boolean reported = reportAggregator.report(req); statistics.totalReportCacheUpdat...
java
public Set<TraceeBackendProvider> getBackendProviders() { // Create a working copy of Cache. Reference is updated upon cache update. final Map<ClassLoader, Set<TraceeBackendProvider>> cacheCopy = providersPerClassloader; // Try to determine TraceeBackendProvider by context classloader. Fallback: use classloader ...
java
Set<TraceeBackendProvider> getDefaultTraceeBackendProvider() { try { final ClassLoader classLoader = GetClassLoader.fromContext(); final Class<?> slf4jTraceeBackendProviderClass = Class.forName("io.tracee.backend.slf4j.Slf4jTraceeBackendProvider", true, classLoader); final TraceeBackendProvider instance = (T...
java
public static java.util.Set<String> all() { java.util.Set<String> set = new java.util.HashSet<String>(); set.add(CLOUD_PLATFORM); set.add(SERVICECONTROL); return java.util.Collections.unmodifiableSet(set); }
java
@Override public void filter(final ClientRequestContext requestContext) { if (!backend.isEmpty() && backend.getConfiguration().shouldProcessContext(OutgoingRequest)) { final Map<String, String> filtered = backend.getConfiguration().filterDeniedParams(backend.copyToMap(), OutgoingRequest); requestContext.getHea...
java
@Override public void filter(final ClientRequestContext requestContext, final ClientResponseContext responseContext) { final List<String> serializedHeaders = responseContext.getHeaders().get(TraceeConstants.TPIC_HEADER); if (serializedHeaders != null && backend.getConfiguration().shouldProcessContext(IncomingRespo...
java