类com.google.common.base.StandardSystemProperty源码实例Demo

下面列出了怎么用com.google.common.base.StandardSystemProperty的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: presto   文件: PrestoSystemRequirements.java
private static void verifyOsArchitecture()
{
    String osName = StandardSystemProperty.OS_NAME.value();
    String osArch = StandardSystemProperty.OS_ARCH.value();
    if ("Linux".equals(osName)) {
        if (!ImmutableSet.of("amd64", "aarch64", "ppc64le").contains(osArch)) {
            failRequirement("Presto requires amd64, aarch64, or ppc64le on Linux (found %s)", osArch);
        }
        if ("aarch64".equals(osArch)) {
            warnRequirement("Support for the ARM architecture is experimental");
        }
        else if ("ppc64le".equals(osArch)) {
            warnRequirement("Support for the POWER architecture is experimental");
        }
    }
    else if ("Mac OS X".equals(osName)) {
        if (!"x86_64".equals(osArch)) {
            failRequirement("Presto requires x86_64 on Mac OS X (found %s)", osArch);
        }
    }
    else {
        failRequirement("Presto requires Linux or Mac OS X (found %s)", osName);
    }
}
 
源代码2 项目: dremio-oss   文件: AppBundleGenerator.java
public static AppBundleGenerator of(DremioConfig config) {

    List<String> nativeLibraryPath = Optional.ofNullable(StandardSystemProperty.JAVA_LIBRARY_PATH.value())
        .map(p -> Arrays.asList(p.split(File.pathSeparator)))
        .orElse(Collections.emptyList());

    final Path pluginsPath = DremioConfig.getPluginsRootPath();

    return new AppBundleGenerator(
        AppBundleGenerator.class.getClassLoader(),
        config.getStringList(DremioConfig.YARN_APP_CLASSPATH_PREFIX),
        config.getStringList(DremioConfig.YARN_APP_CLASSPATH),
        nativeLibraryPath,
        pluginsPath
    );
  }
 
源代码3 项目: dremio-oss   文件: TestYarnDefaultsConfigurator.java
@Test
public void testMaprAppClasspath() {
  assumeMaprProfile();

  final Set<String> jars = Arrays.stream(StandardSystemProperty.JAVA_CLASS_PATH.value().split(":"))
      .map(Paths::get)
      .map(Path::getFileName)
      .map(Path::toString)
      .collect(Collectors.toSet());

  // Sanity check to make sure that jars required to start app are present in the test classpath
  // test itself does not require those jars but it should prevent naming mismatches
  final String appClassPath = YarnDefaultsConfigurator.MapRYarnDefaults.getAppClassPath();
  for(final String path : appClassPath.split(",")) {
    // Just checking filename is present since the layout depends on the actual distribution config
    final String filename = Paths.get(path).getFileName().toString();

    assertTrue(format("jar %s not present in classpath (%s)", filename, jars), checkExist(jars, filename));
  }
}
 
源代码4 项目: dremio-oss   文件: ByteStoreManager.java
private void verifyDBOwner(File dbDirectory) throws IOException {
  // Skip file owner check if running on Windows
  if (StandardSystemProperty.OS_NAME.value().contains("Windows")) {
    return;
  }

  String procUser = StandardSystemProperty.USER_NAME.value();
  File[] dbFiles = dbDirectory.listFiles();
  for (File dbFile : dbFiles) {
    if (dbFile.isDirectory()) {
      continue;
    }

    String dbOwner = Files.getOwner(dbFile.toPath()).getName();
    if (!procUser.equals(dbOwner)) {
      throw new DatastoreException(
        String.format("Process user (%s) doesn't match local catalog db owner (%s).  Please run process as %s.",
          procUser, dbOwner, dbOwner));
    }

    // Break once verified, we assume the rest are owned by the same user.
    break;
  }
}
 
源代码5 项目: dremio-oss   文件: DataPopulatorUtils.java
public static void addDefaultDremioUser(
  final UserService userService,
  final NamespaceService namespaceService) throws Exception {
  if (!userService.hasAnyUser()) {
    createUserIfNotExists(
      userService,
      namespaceService,
      DEFAULT_USER_NAME,
      PASSWORD,
      DEFAULT_USER_FIRSTNAME,
      DEFAULT_USER_LASTNAME);
    // Special case for regression until we move away from views as physical files.
    // View expansion requires the user who wrote the file on the filesystem
    // to be present in the usergroup db
    if (ADD_PROCESS_USER) {
      createUserIfNotExists(
        userService,
        namespaceService,
        StandardSystemProperty.USER_NAME.value(),
        PASSWORD,
        DEFAULT_USER_FIRSTNAME,
        DEFAULT_USER_LASTNAME);
    }
  }
}
 
源代码6 项目: copybara   文件: Main.java
/**
 * Returns the base directory to be used by Copybara to write execution related files (Like
 * logs).
 */
private String getBaseExecDir() {
  // In this case we are not using GeneralOptions.getEnvironment() because we still haven't built
  // the options, but it's fine. This is the tool's Main and is also injecting System.getEnv()
  // to the options, so the value is the same.
  String userHome = StandardSystemProperty.USER_HOME.value();

  switch (StandardSystemProperty.OS_NAME.value()) {
    case "Linux":
      String xdgCacheHome = System.getenv("XDG_CACHE_HOME");
      return Strings.isNullOrEmpty(xdgCacheHome)
          ? userHome + "/.cache/" + COPYBARA_NAMESPACE
          : xdgCacheHome + COPYBARA_NAMESPACE;
    case "Mac OS X":
      return userHome + "/Library/Logs/" + COPYBARA_NAMESPACE;
    default:
      return "/var/tmp/" + COPYBARA_NAMESPACE;
  }
}
 
源代码7 项目: copybara   文件: WorkflowTest.java
@Test
public void testEmptyDescriptionForFolderDestination() throws Exception {
  origin.singleFileChange(/*timestamp=*/44, "commit 1", "bar.txt", "1");
  options
      .setWorkdirToRealTempDir()
      .setHomeDir(StandardSystemProperty.USER_HOME.value());
  new SkylarkTestExecutor(options).loadConfig("core.workflow(\n"
      + "    name = 'foo',\n"
      + "    origin = testing.origin(),\n"
      + "    destination = folder.destination(),\n"
      + "    authoring = " + authoring + ",\n"
      + "    transformations = [metadata.replace_message(''),],\n"
      + ")\n")
      .getMigration("foo")
      .run(workdir, ImmutableList.of());
}
 
源代码8 项目: copybara   文件: WorkflowTest.java
@Test
public void migrationIdentityWithUser() throws Exception {
  // Squash always sets the default author for the commit but not in the release notes
  origin.addSimpleChange(/*timestamp*/ 1);
  String withUser = workflow().getMigrationIdentity(origin.resolve(HEAD), transformWork);

  options.workflowOptions.workflowIdentityUser = StandardSystemProperty.USER_NAME.value();

  assertThat(withUser).isEqualTo(workflow().getMigrationIdentity(origin.resolve(HEAD),
      transformWork));

  options.workflowOptions.workflowIdentityUser = "TEST";

  String withOtherUser = workflow().getMigrationIdentity(origin.resolve(HEAD), transformWork);

  assertThat(withOtherUser).isNotEqualTo(withUser);
}
 
源代码9 项目: scheduling   文件: RMNodeUpdater.java
/**
 * Build the java subprocess which will be spawned from this JVM.
 * @param args current JVM arguments
 * @param jarFile up-to-date node jar file
 * @return
 */
private ProcessBuilder generateSubProcess(String[] args, String jarFile) {
    ProcessBuilder pb;
    List<String> command = new ArrayList<>();
    if (StandardSystemProperty.OS_NAME.value().toLowerCase().contains("windows")) {
        command.add((new File(StandardSystemProperty.JAVA_HOME.value(), "bin/java.exe")).getAbsolutePath());
    } else {
        command.add((new File(StandardSystemProperty.JAVA_HOME.value(), "bin/java")).getAbsolutePath());
    }
    command.addAll(buildJVMOptions());
    command.add("-jar");
    command.add(jarFile);
    command.addAll(removeOptionsUnrecognizedByRMNodeStarter(args));
    logger.info("Starting Java command: " + command);
    pb = new ProcessBuilder(command);
    pb.inheritIO();
    File nodeJarParentFolder = (new File(jarFile)).getParentFile();
    pb.directory(nodeJarParentFolder);
    if (pb.environment().containsKey("CLASSPATH")) {
        pb.environment().remove("CLASSPATH");
    }
    return pb;
}
 
源代码10 项目: kurento-java   文件: KurentoClient.java
public static synchronized String getKmsUrl(String id, Properties properties) {

    if (properties == null) {
      properties = new Properties();
    }

    if (kmsUrlLoader == null) {

      Path configFile =
          Paths.get(StandardSystemProperty.USER_HOME.value(), ".kurento", "config.properties");

      kmsUrlLoader = new KmsUrlLoader(configFile);
    }

    Object load = properties.get("loadPoints");
    if (load == null) {
      return kmsUrlLoader.getKmsUrl(id);
    } else {
      if (load instanceof Number) {
        return kmsUrlLoader.getKmsUrlLoad(id, ((Number) load).intValue());
      } else {
        return kmsUrlLoader.getKmsUrlLoad(id, Integer.parseInt(load.toString()));
      }
    }
  }
 
源代码11 项目: glowroot   文件: TempDirs.java
public static File createTempDir(String prefix) throws IOException {
    final int tempDirAttempts = 10000;
    String javaTempDir =
            MoreObjects.firstNonNull(StandardSystemProperty.JAVA_IO_TMPDIR.value(), ".");
    File baseDir = new File(javaTempDir);
    String baseName = prefix + "-" + System.currentTimeMillis() + "-";
    for (int counter = 0; counter < tempDirAttempts; counter++) {
        File tempDir = new File(baseDir, baseName + counter);
        if (tempDir.mkdir()) {
            return tempDir;
        }
    }
    throw new IOException(
            "Failed to create directory within " + tempDirAttempts + " attempts (tried "
                    + baseName + "0 to " + baseName + (tempDirAttempts - 1) + ')');
}
 
源代码12 项目: glowroot   文件: MainEntryPoint.java
private static StringBuilder getJavaVersion() {
    StringBuilder sb = new StringBuilder();
    sb.append(StandardSystemProperty.JAVA_VERSION.value());
    String vendor = System.getProperty("java.vm.vendor");
    String os = System.getProperty("os.name");
    boolean appendVendor = !Strings.isNullOrEmpty(vendor);
    boolean appendOS = !Strings.isNullOrEmpty(os);
    if (appendVendor && appendOS) {
        sb.append(" (");
        if (appendVendor) {
            sb.append(vendor);
            if (appendOS) {
                sb.append(" / ");
            }
        }
        if (appendOS) {
            sb.append(os);
        }
        sb.append(")");
    }
    return sb;
}
 
源代码13 项目: glowroot   文件: EnvironmentCreator.java
private static JavaInfo createJavaInfo(String glowrootVersion, JvmConfig jvmConfig,
        RuntimeMXBean runtimeMXBean) {
    String jvm = "";
    String javaVmName = StandardSystemProperty.JAVA_VM_NAME.value();
    if (javaVmName != null) {
        jvm = javaVmName + " (" + StandardSystemProperty.JAVA_VM_VERSION.value() + ", "
                + System.getProperty("java.vm.info") + ")";
    }
    String javaVersion = StandardSystemProperty.JAVA_VERSION.value();
    String heapDumpPath = getHeapDumpPathFromCommandLine();
    if (heapDumpPath == null) {
        String javaTempDir =
                MoreObjects.firstNonNull(StandardSystemProperty.JAVA_IO_TMPDIR.value(), ".");
        heapDumpPath = new File(javaTempDir).getAbsolutePath();
    }
    return JavaInfo.newBuilder()
            .setVersion(Strings.nullToEmpty(javaVersion))
            .setVm(jvm)
            .addAllArg(Masking.maskJvmArgs(runtimeMXBean.getInputArguments(),
                    jvmConfig.maskSystemProperties()))
            .setHeapDumpDefaultDir(heapDumpPath)
            .setGlowrootAgentVersion(glowrootVersion)
            .build();
}
 
源代码14 项目: glowroot   文件: JvmTool.java
private static List<String> buildClasspath(@Nullable File glowrootJarFile) {
    if (glowrootJarFile == null || !isShaded()) {
        // this is just to support testing
        List<String> classpath = Lists.newArrayList();
        if (glowrootJarFile != null) {
            classpath.add(glowrootJarFile.getAbsolutePath());
        }
        classpath.addAll(splitClasspath(StandardSystemProperty.JAVA_CLASS_PATH.value()));
        for (String jvmArg : ManagementFactory.getRuntimeMXBean().getInputArguments()) {
            if (jvmArg.startsWith("-Xbootclasspath/a:")) {
                classpath.addAll(
                        splitClasspath(jvmArg.substring("-Xbootclasspath/a:".length())));
                break;
            }
        }
        return classpath;
    } else {
        return ImmutableList.of(glowrootJarFile.getAbsolutePath());
    }
}
 
源代码15 项目: imhotep   文件: KerberosUtils.java
public static void loginFromKeytab(@Nullable String principal, @Nullable String keytabPath) throws IOException {
    // if one of these is set, then assume they meant to set both
    if (!Strings.isNullOrEmpty(principal) || !Strings.isNullOrEmpty(keytabPath)) {
        log.info("Using properties from configuration file");
        with(principal, keytabPath);
    } else {
        // look for the file to be readable for this user
        final String username = StandardSystemProperty.USER_NAME.value();
        final File keytabFile = new File(String.format("/etc/local_keytabs/%1$s/%1$s.keytab", username));
        log.info("Checking for user " + username + " keytab, settings at " + keytabFile.getAbsolutePath());
        if (keytabFile.exists() && keytabFile.canRead()) {
            with(username + "/[email protected]", keytabFile.getAbsolutePath());
        } else {
            log.warn("Unable to find user keytab, maybe the keytab is in ticket from klist");
        }
    }
}
 
源代码16 项目: selenium   文件: RemoteSession.java
protected RemoteSession(
    Dialect downstream,
    Dialect upstream,
    HttpHandler codec,
    SessionId id,
    Map<String, Object> capabilities) {
  this.downstream = Require.nonNull("Downstream dialect", downstream);
  this.upstream = Require.nonNull("Upstream dialect", upstream);
  this.codec = Require.nonNull("Codec", codec);
  this.id = Require.nonNull("Session id", id);
  this.capabilities = Require.nonNull("Capabilities", capabilities);

  File tempRoot = new File(StandardSystemProperty.JAVA_IO_TMPDIR.value(), id.toString());
  Require.stateCondition(tempRoot.mkdirs(), "Could not create directory %s", tempRoot);
  this.filesystem = TemporaryFilesystem.getTmpFsBasedOn(tempRoot);

  CommandExecutor executor = new ActiveSessionCommandExecutor(this);
  this.driver = new Augmenter().augment(new RemoteWebDriver(
      executor,
      new ImmutableCapabilities(getCapabilities())));
}
 
源代码17 项目: selenium   文件: InMemorySession.java
private InMemorySession(WebDriver driver, Capabilities capabilities, Dialect downstream) {
  this.driver = Require.nonNull("Driver", driver);

  Capabilities caps;
  if (driver instanceof HasCapabilities) {
    caps = ((HasCapabilities) driver).getCapabilities();
  } else {
    caps = capabilities;
  }

  this.capabilities = caps.asMap().entrySet().stream()
      .filter(e -> e.getValue() != null)
      .collect(ImmutableMap.toImmutableMap(Map.Entry::getKey, Map.Entry::getValue));

  this.id = new SessionId(UUID.randomUUID().toString());
  this.downstream = Require.nonNull("Downstream dialect", downstream);

  File tempRoot = new File(StandardSystemProperty.JAVA_IO_TMPDIR.value(), id.toString());
  Require.stateCondition(tempRoot.mkdirs(), "Could not create directory %s", tempRoot);
  this.filesystem = TemporaryFilesystem.getTmpFsBasedOn(tempRoot);

  this.handler = new JsonHttpCommandHandler(
      new PretendDriverSessions(),
      LOG);
}
 
源代码18 项目: selenium   文件: CoreSelfTest.java
@Test
public void executeTests() throws IOException {
  String testBase = server.whereIs("/common/rc/tests");
  Path outputFile = Paths.get(StandardSystemProperty.JAVA_IO_TMPDIR.value())
    .resolve("core-test-suite" + browser.replace('*', '-') + ".html");
  if (Files.exists(outputFile)) {
    Files.delete(outputFile);
  }
  Files.createDirectories(outputFile.getParent());

  String result = new HTMLLauncher()
    .runHTMLSuite(
      browser,
      // We need to do this because the path relativizing code in java.net.URL is
      // We need to do this because the path relativizing code in java.net.URL is
      // clearly having a bad day. "/selenium-server/tests" appended to "../tests/"
      // ends up as "/tests" rather than "/selenium-server/tests" as you'd expect.
      testBase + "/TestSuite.html",
      testBase + "/TestSuite.html",
      outputFile.toFile(),
      TimeUnit.MINUTES.toSeconds(5),
      null);

  assertEquals("PASSED", result);
}
 
源代码19 项目: buck   文件: BuildEnvironmentDescription.java
public static BuildEnvironmentDescription of(
    ExecutionEnvironment executionEnvironment,
    ImmutableList<String> cacheModes,
    ImmutableMap<String, String> extraData) {
  Optional<Boolean> buckDirty;
  String dirty = System.getProperty("buck.git_dirty", "unknown");
  if (dirty.equals("1")) {
    buckDirty = Optional.of(true);
  } else if (dirty.equals("0")) {
    buckDirty = Optional.of(false);
  } else {
    buckDirty = Optional.empty();
  }

  return of(
      executionEnvironment.getUsername(),
      executionEnvironment.getHostname(),
      executionEnvironment.getPlatform().getPrintableName().toLowerCase().replace(' ', '_'),
      executionEnvironment.getAvailableCores(),
      executionEnvironment.getTotalMemory(),
      buckDirty,
      System.getProperty("buck.git_commit", "unknown"),
      Objects.requireNonNull(StandardSystemProperty.JAVA_VM_VERSION.value()),
      cacheModes,
      extraData);
}
 
源代码20 项目: auto   文件: OverridesTest.java
private void evaluate(File dummySourceFile) throws Throwable {
  JavaCompiler compiler = new EclipseCompiler();
  StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, UTF_8);
  // This hack is only needed in a Google-internal Java 8 environment where symbolic links make
  // it hard for ecj to find the boot class path. Elsewhere it is unnecessary but harmless.
  File rtJar = new File(StandardSystemProperty.JAVA_HOME.value() + "/lib/rt.jar");
  if (rtJar.exists()) {
    List<File> bootClassPath = ImmutableList.<File>builder()
        .add(rtJar)
        .addAll(fileManager.getLocation(StandardLocation.PLATFORM_CLASS_PATH))
        .build();
    fileManager.setLocation(StandardLocation.PLATFORM_CLASS_PATH, bootClassPath);
  }
  Iterable<? extends JavaFileObject> sources = fileManager.getJavaFileObjects(dummySourceFile);
  JavaCompiler.CompilationTask task =
      compiler.getTask(null, fileManager, null, null, null, sources);
  EcjTestProcessor processor = new EcjTestProcessor(statement);
  task.setProcessors(ImmutableList.of(processor));
  assertThat(task.call()).isTrue();
  processor.maybeThrow();
}
 
源代码21 项目: presto   文件: PrestoServer.java
public static void main(String[] args)
{
    String javaVersion = nullToEmpty(StandardSystemProperty.JAVA_VERSION.value());
    String majorVersion = javaVersion.split("[^\\d]", 2)[0];
    Integer major = Ints.tryParse(majorVersion);
    if (major == null || major < 11) {
        System.err.println(format("ERROR: Presto requires Java 11+ (found %s)", javaVersion));
        System.exit(100);
    }

    String version = PrestoServer.class.getPackage().getImplementationVersion();
    new Server().start(firstNonNull(version, "unknown"));
}
 
源代码22 项目: presto   文件: OkHttpUtil.java
private static boolean isAtLeastJava11()
{
    String feature = Splitter.on(".").split(StandardSystemProperty.JAVA_VERSION.value()).iterator().next();
    try {
        return Integer.parseInt(feature) >= 11;
    }
    catch (NumberFormatException e) {
        return false;
    }
}
 
源代码23 项目: presto   文件: TestHiveS3Config.java
@Test
public void testDefaults()
{
    assertRecordedDefaults(recordDefaults(HiveS3Config.class)
            .setS3AwsAccessKey(null)
            .setS3AwsSecretKey(null)
            .setS3Endpoint(null)
            .setS3SignerType(null)
            .setS3SignerClass(null)
            .setS3PathStyleAccess(false)
            .setS3IamRole(null)
            .setS3ExternalId(null)
            .setS3StorageClass(PrestoS3StorageClass.STANDARD)
            .setS3SslEnabled(true)
            .setS3SseEnabled(false)
            .setS3SseType(PrestoS3SseType.S3)
            .setS3SseKmsKeyId(null)
            .setS3KmsKeyId(null)
            .setS3EncryptionMaterialsProvider(null)
            .setS3MaxClientRetries(5)
            .setS3MaxErrorRetries(10)
            .setS3MaxBackoffTime(new Duration(10, TimeUnit.MINUTES))
            .setS3MaxRetryTime(new Duration(10, TimeUnit.MINUTES))
            .setS3ConnectTimeout(new Duration(5, TimeUnit.SECONDS))
            .setS3SocketTimeout(new Duration(5, TimeUnit.SECONDS))
            .setS3MultipartMinFileSize(DataSize.of(16, Unit.MEGABYTE))
            .setS3MultipartMinPartSize(DataSize.of(5, Unit.MEGABYTE))
            .setS3MaxConnections(500)
            .setS3StagingDirectory(new File(StandardSystemProperty.JAVA_IO_TMPDIR.value()))
            .setPinS3ClientToCurrentRegion(false)
            .setS3UserAgentPrefix("")
            .setS3AclType(PrestoS3AclType.PRIVATE)
            .setSkipGlacierObjects(false)
            .setRequesterPaysEnabled(false));
}
 
源代码24 项目: n4js   文件: SshSessionFactory.java
private JSch configureIdentity(final JSch jsch) throws JSchException {

		final File sshDirectory = new File(StandardSystemProperty.USER_HOME.value() + "/.ssh");
		checkState(sshDirectory.exists(), ".ssh directory does not exist under home folder.");
		checkState(sshDirectory.canRead(), ".ssh directory content cannot be read.");
		checkState(sshDirectory.isDirectory(), sshDirectory.getAbsoluteFile() + " is not a directory.");
		final File[] keyFiles = sshDirectory.listFiles();
		checkState(null != keyFiles && keyFiles.length > 0, "No SSH key files exist.");

		jsch.removeAllIdentity();
		for (final File keyFile : keyFiles) {
			if (keyFile.isFile()) {
				final String keyUri = keyFile.toURI().toString();
				final int lastIndexOf = keyUri.lastIndexOf("/");
				if (lastIndexOf > 0) {
					final String keyFileName = keyUri.substring(lastIndexOf + 1);
					if ("id_rsa".equals(keyFileName) || "id_dsa".equals(keyFileName)) {
						if (isEncrypted(keyFile)) {
							String pw = getPassphrase(keyFile);
							jsch.addIdentity(keyFile.getAbsolutePath(), pw);
						} else {
							jsch.addIdentity(keyFile.getAbsolutePath());
						}

						break;
					}
				}
			}
		}

		return jsch;
	}
 
源代码25 项目: dremio-oss   文件: AppBundleGenerator.java
private List<URI> addJavaLibraryPathToBundle(JarGenerator jarGenerator) throws IOException {
  String javaLibraryPath = StandardSystemProperty.JAVA_LIBRARY_PATH.value();
  if (javaLibraryPath == null) {
    return Collections.emptyList();
  }

  return addPathsToBundle(jarGenerator, Stream.of(javaLibraryPath.split(File.pathSeparator)).map(Paths::get));
}
 
源代码26 项目: dremio-oss   文件: TestStoreQueryResults.java
private static String localQueryHelper(String query, String storeTblName, boolean checkWriterDistributionTrait) throws Exception {
  LocalQueryExecutor localQueryExecutor = getLocalQueryExecutor();

  RunQuery queryCmd = RunQuery
      .newBuilder()
      .setType(UserBitShared.QueryType.SQL)
      .setSource(SubmissionSource.LOCAL)
      .setPlan(query)
      .build();

  String queryResultsStorePath = format("%s.\"%s\"", TEMP_SCHEMA, storeTblName);
  LocalExecutionConfig config = LocalExecutionConfig.newBuilder()
      .setEnableLeafLimits(false)
      .setFailIfNonEmptySent(false)
      .setUsername(StandardSystemProperty.USER_NAME.value())
      .setSqlContext(Collections.<String>emptyList())
      .setInternalSingleThreaded(false)
      .setQueryResultsStorePath(queryResultsStorePath)
      .setAllowPartitionPruning(true)
      .setExposeInternalSources(false)
      .setSubstitutionSettings(SubstitutionSettings.of())
      .build();

  TestQueryObserver queryObserver = new TestQueryObserver(checkWriterDistributionTrait);
  localQueryExecutor.submitLocalQuery(ExternalIdHelper.generateExternalId(), queryObserver, queryCmd, false, config, false);

  queryObserver.waitForCompletion();

  return toTableName(TEMP_SCHEMA, storeTblName, queryObserver.getAttemptId());
}
 
源代码27 项目: dremio-oss   文件: ITTestLimit.java
@Test
public void testLimitOne() throws Exception {
  String query = String.format("select * from elasticsearch.%s.%s limit 1", schema, table);
  LocalExecutionConfig config = LocalExecutionConfig.newBuilder()
    .setEnableLeafLimits(false)
    .setFailIfNonEmptySent(false)
    .setUsername(StandardSystemProperty.USER_NAME.value())
    .setSqlContext(Collections.<String>emptyList())
    .setInternalSingleThreaded(false)
    .setQueryResultsStorePath(format("%s.\"%s\"", TEMP_SCHEMA, "elasticLimitOne"))
    .setAllowPartitionPruning(true)
    .setExposeInternalSources(false)
    .setSubstitutionSettings(SubstitutionSettings.of())
    .build();

  RunQuery queryCmd = RunQuery
    .newBuilder()
    .setType(UserBitShared.QueryType.SQL)
    .setSource(SubmissionSource.LOCAL)
    .setPlan(query)
    .build();

  ProfileGrabber grabber = new ProfileGrabber();
  getLocalQueryExecutor().submitLocalQuery(ExternalIdHelper.generateExternalId(), grabber, queryCmd, false, config, false);
  QueryProfile profile = grabber.getProfile();

  Optional<OperatorProfile> scanProfile = profile.getFragmentProfile(0)
    .getMinorFragmentProfile(0).getOperatorProfileList().stream()
    .filter(operatorProfile -> operatorProfile.getOperatorType() == CoreOperatorType.ELASTICSEARCH_SUB_SCAN_VALUE)
    .findFirst();
  assertEquals(1L, scanProfile.get().getInputProfile(0).getRecords());
}
 
源代码28 项目: copybara   文件: Identity.java
public static String hashIdentity(ToStringHelper helper, String workflowIdentityUser) {
  helper.add(
      "user",
      workflowIdentityUser != null
          ? workflowIdentityUser
          : StandardSystemProperty.USER_NAME.value());
  String identity = helper.toString();
  String hash =
      BaseEncoding.base16()
          .encode(Hashing.md5().hashString(identity, StandardCharsets.UTF_8).asBytes());
  // Important to log the source of the hash and the hash for debugging purposes.
  logger.atInfo().log("Computed migration identity hash for %s as %s ", identity, hash);
  return hash;
}
 
源代码29 项目: copybara   文件: OptionsBuilder.java
public OptionsBuilder setOutputRootToTmpDir() {
  // Using Files.createTempDirectory() generates paths > 255 in some tests and that causes
  // 'File name too long' exceptions in Linux
  general.setOutputRootPathForTest(
      FileSystems.getDefault().getPath(StandardSystemProperty.JAVA_IO_TMPDIR.value()));
  return this;
}
 
源代码30 项目: copybara   文件: WorkflowTest.java
@Test
public void testTestWorkflowWithDiffInOrigin() throws Exception {
  GitRepository remote = GitRepository.newBareRepo(
      Files.createTempDirectory("gitdir"), getGitEnv(), /*verbose=*/true,
      DEFAULT_TIMEOUT, /*noVerify=*/ false).withWorkTree(workdir);
  remote.init();

  Files.write(workdir.resolve("foo.txt"), new byte[]{});
  remote.add().files("foo.txt").run();
  remote.simpleCommand("commit", "foo.txt", "-m", "message_a");
  GitRevision lastRev = remote.resolveReference("master");

  Files.write(workdir.resolve("bar.txt"), "change content".getBytes(UTF_8));
  remote.add().files("bar.txt").run();
  remote.simpleCommand("commit", "bar.txt", "-m", "message_s");

  TestingConsole testingConsole = new TestingConsole().respondYes();
  options.workflowOptions.lastRevision = lastRev.getSha1();
  options
      .setWorkdirToRealTempDir()
      .setConsole(testingConsole)
      .setHomeDir(StandardSystemProperty.USER_HOME.value());

  Workflow<?, ?> workflow =
      (Workflow<?, ?>) new SkylarkTestExecutor(options).loadConfig(
          "core.workflow(\n"
              + "    name = 'foo',\n"
              + "    origin = git.origin(url='" + remote.getGitDir() + "'),\n"
              + "    destination = folder.destination(),\n"
              + "    mode = 'ITERATIVE',\n"
              + "    authoring = " + authoring + ",\n"
              + "    transformations = [metadata.replace_message(''),],\n"
              + ")\n")
          .getMigration("foo");
  workflow.getWorkflowOptions().diffInOrigin = true;
  workflow.run(workdir, ImmutableList.of("master"));
  testingConsole.assertThat()
      .onceInLog(MessageType.WARNING, "Change 1 of 1 \\(.*\\)\\: Continue to migrate with '"
          + workflow.getMode() + "'" + " to " + workflow.getDestination().getType() + "\\?");
}