Java源码示例:com.indeed.util.varexport.VarExporter

示例1
@VisibleForTesting
Proctor(
        final TestMatrixArtifact matrix,
        final ProctorLoadResult loadResult,
        @Nonnull final Map<String, TestChooser<?>> testChoosers
) {
    this.matrix = matrix;
    this.loadResult = loadResult;
    this.testChoosers = testChoosers;
    for (final Entry<String, TestChooser<?>> entry : testChoosers.entrySet()) {
        this.testDefinitions.put(entry.getKey(), entry.getValue().getTestDefinition());
    }

    VarExporter.forNamespace(Proctor.class.getSimpleName()).includeInGlobal().export(this, "");
    VarExporter.forNamespace(DetailedExport.class.getSimpleName()).export(new DetailedExport(), "");  //  intentionally not in global
}
 
示例2
public ProctorStore createStore(final String relativePath) {
    final File tempDirectory = createTempDirectoryForPath(relativePath);

    Preconditions.checkArgument(StringUtils.isNotBlank(gitUrl), "scm.path property cannot be empty");

    final GitWorkspaceProviderImpl provider = new GitWorkspaceProviderImpl(tempDirectory, gitDirectoryLockTimeoutSeconds);
    final GitProctorCore gitCore = new GitProctorCore(gitUrl, gitUsername, gitPassword, testDefinitionsDirectory,
            provider, gitPullPushTimeoutSeconds, gitCloneTimeoutSeconds, gitCleanInitialization);

    final String branchName = relativePath.substring(relativePath.lastIndexOf("/") + 1);
    final GitProctor store = new GitProctor(gitCore, testDefinitionsDirectory, branchName);
    final String prefix = relativePath.replace('/', '-');
    final VarExporter exporter = VarExporter.forNamespace(GitProctor.class.getSimpleName()).includeInGlobal();
    exporter.export(store, prefix + "-");
    return createStoreWithGlobalCache(branchName, new CachingProctorStore(store));
}
 
示例3
public AbstractDependencyManager(
        @Nullable final String appName,
        @Nullable final Logger logger,
        @Nonnull final ThreadPoolExecutor threadPool,
        @Nonnull final DependencyChecker checker
) {
    this.appName = Strings.isNullOrEmpty(appName) ? getAppName() : appName;
    this.log = null == logger ? Logger.getLogger(getClass()) : logger;

    this.executor = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryBuilder()
            .setNameFormat("dependency-management-" + MANAGEMENT_THREAD_POOL_COUNT.getAndIncrement() + "-thread-%d")
            .setDaemon(true)
            .setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
                @Override
                public void uncaughtException(Thread t, Throwable e) {
                    log.error("Uncaught throwable in thread " + t.getName() + "/" + t.getId(), e);
                }
            })
            .build()
    );

    this.threadPool = threadPool;

    this.checker = checker;

    VarExporter.forNamespace(getClass().getSimpleName()).includeInGlobal().export(this, "");
}
 
示例4
DependencyPinger (
        @Nonnull final Dependency dependency,
        final long pingPeriod,
        @Nonnull final DependencyChecker dependencyChecker
) {
    this.checker = dependencyChecker;
    this.dependency = dependency;
    this.pingPeriod = pingPeriod;

    VarExporter.forNamespace(DependencyPinger.class.getSimpleName() + "-" + this.dependency.getId()).includeInGlobal().export(this, "");
}
 
示例5
@Test
public void testExportedVariableForSpecification() {
    final JsonProctorLoaderFactory factory = new JsonProctorLoaderFactory();
    factory.setFilePath(getClass().getResource("example-test-matrix.json").getPath());
    factory.setSpecificationResource("classpath:specification-with-filter.json");
    assertThat(
            VarExporter.forNamespace("JsonProctorLoaderFactory")
                    .<String>getValue("specification-specification-with-filter.json")
    ).contains("example");
}
 
示例6
public ProctorStore createStore(final String relativePath) {
    Preconditions.checkArgument(tempDirCleanupAgeMillis > 0, "tempDirCleanupAgeMillis %s must be greater than zero", tempDirCleanupAgeMillis);
    final File tempDirectory = createTempDirectoryForPath(relativePath);

    Preconditions.checkArgument(StringUtils.isNotBlank(svnPath), "svn.path property cannot be empty");
    // TODO (parker) 9/13/12 - sanity check that path + relative path make a valid url
    final String fullPath = svnPath + relativePath;

    final SvnWorkspaceProviderImpl provider = new SvnWorkspaceProviderImpl(tempDirectory, tempDirCleanupAgeMillis);
    final SvnPersisterCoreImpl svncore = new SvnPersisterCoreImpl(fullPath, svnUsername, svnPassword, testDefinitionsDirectory, provider, true /* shutdown provider */);

    // actively clean up directories every hour: (not relying on cache eviction)
    final long cleanupScheduleMillis = Math.min(TimeUnit.HOURS.toMillis(1), tempDirCleanupAgeMillis);
    LOGGER.info("Scheduling SvnWorkspaceProvider every " + cleanupScheduleMillis + " milliseconds for dir: " + tempDirectory + " with age millis " + tempDirCleanupAgeMillis);
    executor.scheduleWithFixedDelay(provider, cleanupScheduleMillis, cleanupScheduleMillis, TimeUnit.MILLISECONDS);

    if (svnRefreshMillis > 0) {
        final SvnDirectoryRefresher refresher = svncore.createRefresherTask();
        LOGGER.info("Scheduling SvnDirectoryRefresher every " + svnRefreshMillis + " milliseconds for dir: " + refresher.getDirectoryPath());
        executor.scheduleWithFixedDelay(refresher, svnRefreshMillis, svnRefreshMillis, TimeUnit.MILLISECONDS);
    }

    final SvnProctor store = new SvnProctor(cache ? new CachedSvnPersisterCore(svncore) : svncore, testDefinitionsDirectory);
    final VarExporter exporter = VarExporter.forNamespace(SvnProctor.class.getSimpleName()).includeInGlobal();
    final String prefix = relativePath.substring(1).replace('/', '-');
    exporter.export(store, prefix + "-");
    return store;
}
 
示例7
@Override
public void afterPropertiesSet() throws Exception {
    scheduledExecutorService.scheduleWithFixedDelay(proctorSpecificationSource, 1, 10, TimeUnit.MINUTES);

    if (scheduledExecutorService instanceof ThreadPoolExecutor) {
        VarExporter.forNamespace(getClass().getSimpleName()).export(new ThreadPoolExecutorVarExports((ThreadPoolExecutor) scheduledExecutorService), "pool-");
    }
}
 
示例8
public ProctorPromoter(final ProctorStore trunk,
                       final ProctorStore qa,
                       final ProctorStore production,
                       final ExecutorService executor) {
    this.trunk = trunk;
    this.qa = qa;
    this.production = production;
    if (executor instanceof ThreadPoolExecutor) {
        final VarExporter exporter = VarExporter.forNamespace(getClass().getSimpleName());
        exporter.export(new ThreadPoolExecutorVarExports((ThreadPoolExecutor) executor), "ProctorPromoter-pool-");
    }
    this.executor = executor;
}
 
示例9
private void showNamespaces(final String uri, final HttpServletResponse response) throws IOException {
    final List<String> namespaces = VarExporter.getNamespaces();
    namespaces.remove(null);
    Collections.sort(namespaces);

    final Map<String, String> parents = Maps.newHashMapWithExpectedSize(namespaces.size());
    for (String namespace : namespaces) {
        VarExporter parent = VarExporter.forNamespace(namespace).getParentNamespace();
        if (parent == null) {
            parents.put(namespace, "none");
        } else {
            parents.put(namespace, parent.getNamespace());
        }
    }

    response.setContentType("text/html");
    final PrintWriter out = response.getWriter();
    final Map<String, Object> root = new HashMap<String, Object>();
    root.put("urlPath", uri);
    root.put("namespaces", namespaces);
    root.put("parents", parents);
    try {
        browseNamespaceTemplate.process(root, out);
    } catch (Exception e) {
        throw new IOException("template failure", e);
    }
    out.flush();
    out.close();
}
 
示例10
protected void showVariables(
        final String uri,
        final HttpServletResponse response,
        final String namespace,
        final String tag,
        final boolean includeDoc,
        final DisplayType displayType,
        final String... vars
) throws IOException {
    final VariableHost exporter;
    if (!Strings.isNullOrEmpty(tag)) {
        exporter = VarExporter.withTag(tag);
    } else if (!Strings.isNullOrEmpty(namespace)) {
        exporter = VarExporter.forNamespace(namespace);
    } else {
        exporter = VarExporter.global();
    }
    final PrintWriter out = response.getWriter();
    response.setContentType(displayType.mimeType);

    switch(displayType) {
        case HTML:
            showUsingTemplate(exporter, uri, namespace, includeDoc, varHtmlTemplate, true, out, vars);
            break;
        case PLAINTEXT:
            showUsingTemplate(exporter, uri, namespace, includeDoc, varTextTemplate, false, out, vars);
            break;
        // TODO: support json -- exporter JSON is currently broken
    }

    out.flush();
    out.close();
}
 
示例11
@Test
public void testManagedVariables() throws IOException {
    final ManagedVariable<String> var1 = ManagedVariable.<String>builder().setName("test1").setValue("1").build();
    final ManagedVariable<String> var2 = ManagedVariable.<String>builder().setName("test2").setValue("2").build();
    VarExporter.global().export(var1);
    VarExporter.global().export(var2);
    final ViewExportedVariablesServlet servlet = setupServlet();
    assertLines(getOutput(servlet, "", ""), "test1=1", "test2=2");
}
 
示例12
@Test
public void testTags() throws IOException {
    VarExporter.global().export(new TagExamples(), "");
    final ViewExportedVariablesServlet servlet = setupServlet();
    assertLines(getOutput(servlet, "", "VEVST1"), "ex1field=1", "ex2method=2");
    assertLines(getOutput(servlet, "", "VEVST2"), "ex2field=2", "ex4field=four");
    assertLines(getOutput(servlet, "", "VEVST3"), "ex3field=3", "ex1method=1");
    assertLines(getOutput(servlet, "", "nothing"), "null");
}
 
示例13
public LocalSessionManager() {
    VarExporter.forNamespace(getClass().getSimpleName()).includeInGlobal().export(this, "");
}
 
示例14
public ImhotepMemoryPool(long capacityInBytes) {
    this.capacityInBytes = capacityInBytes;

    VarExporter.forNamespace(getClass().getSimpleName()).includeInGlobal().export(this, "");
}
 
示例15
public CachedMemoryReserver(final MemoryReserver wrapped, final ImhotepMemoryCache cache) {
    this.wrapped = wrapped;
    this.cache = cache;

    VarExporter.forNamespace(getClass().getSimpleName()).includeInGlobal().export(this, "");
}
 
示例16
@BeforeClass
public static void quietLogs() {
    Logger.getLogger(VarExporter.class).setLevel(Level.FATAL);
}
 
示例17
public ServletContextConfiguredPropertyPlaceholderConfigurer() {
    VarExporter.forNamespace("ResourceConfig").includeInGlobal().export(this, "");
}
 
示例18
public BackgroundJobManager(final ThreadPoolExecutor executor) {
    final VarExporter exporter = VarExporter.forNamespace(getClass().getSimpleName());

    exporter.export(new ThreadPoolExecutorVarExports(executor), "pool-");
    this.service = executor;
}
 
示例19
@Before
public void setUp() throws Exception {
    VarExporter.resetGlobal();
}
 
示例20
PackageClass() {
    VarExporter.forNamespace("external").export(this, "");
}
 
示例21
public DataLoadingRunnable(String namespace) {
    VarExporter.forNamespace(namespace).includeInGlobal().export(this, "");
}
 
示例22
public DataLoadingTimerTask(String namespace) {
    VarExporter.forNamespace(namespace).includeInGlobal().export(this, "");
}