Example usage for com.google.common.base StandardSystemProperty USER_NAME

List of usage examples for com.google.common.base StandardSystemProperty USER_NAME

Introduction

In this page you can find the example usage for com.google.common.base StandardSystemProperty USER_NAME.

Prototype

StandardSystemProperty USER_NAME

To view the source code for com.google.common.base StandardSystemProperty USER_NAME.

Click Source Link

Document

User's account name.

Usage

From source file:com.indeed.imhotep.builder.tsv.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);//from w ww .j a v  a  2s .  c o  m
    } 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 + "/_HOST@INDEED.NET", keytabFile.getAbsolutePath());
        } else {
            log.warn("Unable to find user keytab, maybe the keytab is in ticket from klist");
        }
    }
}

From source file:ec.nbdemetra.ui.interchange.impl.Configs.java

public static Configs fromExportables(List<? extends Exportable> exportables) {
    ImmutableList.Builder<Config> items = ImmutableList.builder();
    for (Exportable o : exportables) {
        items.add(o.exportConfig());/*w w w . j av  a  2  s  . c o m*/
    }
    return new Configs(StandardSystemProperty.USER_NAME.value(), System.currentTimeMillis(), items.build());
}

From source file:com.facebook.presto.hive.HiveWriteUtils.java

public static Path createTemporaryPath(HdfsEnvironment hdfsEnvironment, Path targetPath) {
    // use a per-user temporary directory to avoid permission problems
    // TODO: this should use Hadoop UserGroupInformation
    String temporaryPrefix = "/tmp/presto-" + StandardSystemProperty.USER_NAME.value();

    // create a temporary directory on the same filesystem
    Path temporaryRoot = new Path(targetPath, temporaryPrefix);
    Path temporaryPath = new Path(temporaryRoot, randomUUID().toString());

    createDirectory(hdfsEnvironment, temporaryPath);

    return temporaryPath;
}

From source file:com.netflix.metacat.s3.connector.S3DetailMetadata.java

@Override
public ConnectorOutputTableHandle beginCreateTable(final ConnectorSession session,
        final ConnectorTableMetadata tableMetadata) {

    Preconditions.checkArgument(!Strings.isNullOrEmpty(tableMetadata.getOwner()),
            "Table owner is null or empty");

    final HiveStorageFormat hiveStorageFormat = HiveTableProperties
            .getHiveStorageFormat(tableMetadata.getProperties());
    final ImmutableList.Builder<String> columnNames = ImmutableList.builder();
    final ImmutableList.Builder<Type> columnTypes = ImmutableList.builder();

    // get the root directory for the database
    final SchemaTableName schemaTableName = tableMetadata.getTable();
    final String schemaName = schemaTableName.getSchemaName();
    final String tableName = schemaTableName.getTableName();

    buildColumnInfo(tableMetadata, columnNames, columnTypes);

    final Path targetPath = getTargetPath(schemaName, tableName, schemaTableName);

    // use a per-user temporary directory to avoid permission problems
    // TODO: this should use Hadoop UserGroupInformation
    final String temporaryPrefix = "/tmp/presto-" + StandardSystemProperty.USER_NAME.value();

    // create a temporary directory on the same filesystem
    final Path temporaryRoot = new Path(targetPath, temporaryPrefix);
    final Path temporaryPath = new Path(temporaryRoot, UUID.randomUUID().toString());
    createDirectories(temporaryPath);//ww w .j av  a  2 s. com

    return new HiveOutputTableHandle(connectorId.toString(), schemaName, tableName, columnNames.build(),
            columnTypes.build(), tableMetadata.getOwner(), targetPath.toString(), temporaryPath.toString(),
            hiveStorageFormat);
}