本文整理汇总了Java中com.google.common.base.StandardSystemProperty类的典型用法代码示例。如果您正苦于以下问题:Java StandardSystemProperty类的具体用法?Java StandardSystemProperty怎么用?Java StandardSystemProperty使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
StandardSystemProperty类属于com.google.common.base包,在下文中一共展示了StandardSystemProperty类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: startTelemetryClient
import com.google.common.base.StandardSystemProperty; //导入依赖的package包/类
private static void startTelemetryClient() {
TelemetryConfiguration telemetryConfiguration = TelemetryConfiguration.getActive();
telemetryConfiguration.setInstrumentationKey(Globals.BUILD_INFO.getAzureInstrumentationKey());
telemetryConfiguration.setTrackingIsDisabled(!Globals.prefs.shouldCollectTelemetry());
telemetryClient = new TelemetryClient(telemetryConfiguration);
telemetryClient.getContext().getProperties().put("JabRef version", Globals.BUILD_INFO.getVersion().toString());
telemetryClient.getContext().getProperties().put("Java version", StandardSystemProperty.JAVA_VERSION.value());
telemetryClient.getContext().getUser().setId(Globals.prefs.getOrCreateUserId());
telemetryClient.getContext().getSession().setId(UUID.randomUUID().toString());
telemetryClient.getContext().getDevice().setOperatingSystem(StandardSystemProperty.OS_NAME.value());
telemetryClient.getContext().getDevice().setOperatingSystemVersion(StandardSystemProperty.OS_VERSION.value());
telemetryClient.getContext().getDevice().setScreenResolution(
Toolkit.getDefaultToolkit().getScreenSize().toString());
telemetryClient.trackSessionState(SessionState.Start);
}
示例2: pathsOverlap
import com.google.common.base.StandardSystemProperty; //导入依赖的package包/类
private boolean pathsOverlap(String firstPath, String secondPath) {
if (firstPath.equals(secondPath)) {
return true;
}
String shorter;
String longer;
if (firstPath.length() > secondPath.length()) {
shorter = secondPath;
longer = firstPath;
} else {
shorter = firstPath;
longer = secondPath;
}
return longer.startsWith(shorter + StandardSystemProperty.FILE_SEPARATOR.value());
}
示例3: configureIdentity
import com.google.common.base.StandardSystemProperty; //导入依赖的package包/类
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;
}
示例4: groups
import com.google.common.base.StandardSystemProperty; //导入依赖的package包/类
private void groups(ServerBootstrap b) {
if (StandardSystemProperty.OS_NAME.value().equals("Linux")) {
bossGroup = new EpollEventLoopGroup(1);
workerGroup = new EpollEventLoopGroup();
b.channel(EpollServerSocketChannel.class)
.group(bossGroup, workerGroup)
.option(EpollChannelOption.TCP_CORK, true);
} else {
bossGroup = new NioEventLoopGroup(1);
workerGroup = new NioEventLoopGroup();
b.channel(NioServerSocketChannel.class)
.group(bossGroup, workerGroup);
}
b.option(ChannelOption.TCP_NODELAY, true)
.option(ChannelOption.SO_REUSEADDR, true)
.option(ChannelOption.SO_BACKLOG, 100);
logger.info("Bootstrap configuration: " + b.toString());
}
示例5: execute
import com.google.common.base.StandardSystemProperty; //导入依赖的package包/类
@Override
protected void execute() throws Exception {
checkState(!inputs.isEmpty(), "input is not set");
RxJavaBdioDocument document = new RxJavaBdioDocument(new BdioOptions.Builder().build());
StreamSupplier out = new BdioWriter.BdioFile(output.openStream());
BdioMetadata metadata = new BdioMetadata();
metadata.id(id.orElseGet(BdioObject::randomId));
metadata.publisher(ProductList.of(getProduct()));
metadata.creationDateTime(ZonedDateTime.now());
metadata.creator(StandardSystemProperty.USER_NAME.value());
// Read all the configured inputs into a single sequence of entries
Flowable<InputStream> data = Flowable.fromIterable(inputs).map(ByteSource::openStream);
// Only collect limited entries for metadata if possible
document.metadata(data.flatMap(in -> document.read(in).takeUntil((Predicate<Object>) ConcatenateTool::needsMoreMetadata)))
.subscribe(m -> combineMetadata(metadata, m))
.isDisposed();
// Write the all the entries back out using the new metadata
data.flatMap(document::read).subscribe(document.write(metadata, out));
}
示例6: computeIdentity
import com.google.common.base.StandardSystemProperty; //导入依赖的package包/类
private String computeIdentity(String type, String ref) {
ToStringHelper helper = MoreObjects.toStringHelper(type)
.add("type", "workflow")
.add("config_path", mainConfigFile.relativeToRoot())
.add("workflow_name", this.name)
.add("context_ref", ref);
helper.add("user", workflowOptions.workflowIdentityUser != null
? workflowOptions.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.info("Computed migration identity hash for " + identity + " as " + hash);
return hash;
}
示例7: getBaseExecDir
import com.google.common.base.StandardSystemProperty; //导入依赖的package包/类
/**
* 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;
}
}
示例8: before
import com.google.common.base.StandardSystemProperty; //导入依赖的package包/类
@Before
public void before() {
try {
final Path tmpPath = Paths.get(StandardSystemProperty.JAVA_IO_TMPDIR.value());
StringConcatenation _builder = new StringConcatenation();
_builder.append("tempFolder_");
UUID _randomUUID = UUID.randomUUID();
_builder.append(_randomUUID);
final Path output = Files.createTempDirectory(tmpPath, _builder.toString());
final Path resource = Files.createFile(output.resolve(URIBasedFileSystemAccessTest.EXISTING_RESOURCE_NAME));
resource.toFile().deleteOnExit();
output.toFile().deleteOnExit();
final OutputConfiguration config = IterableExtensions.<OutputConfiguration>head(this.configProvider.getOutputConfigurations());
config.setOutputDirectory(output.toString());
Pair<String, OutputConfiguration> _mappedTo = Pair.<String, OutputConfiguration>of(IFileSystemAccess.DEFAULT_OUTPUT, config);
this.fsa.setOutputConfigurations(Collections.<String, OutputConfiguration>unmodifiableMap(CollectionLiterals.<String, OutputConfiguration>newHashMap(_mappedTo)));
this.fsa.setConverter(this.uriConverter);
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
示例9: logSplitDocIdsTobeDeleted
import com.google.common.base.StandardSystemProperty; //导入依赖的package包/类
private void logSplitDocIdsTobeDeleted(DBObject query) {
// Fetch only the id
final BasicDBObject keys = new BasicDBObject(Document.ID, 1);
List<String> ids;
DBCursor cursor = getNodeCollection().find(query, keys)
.setReadPreference(store.getConfiguredReadPreference(Collection.NODES));
try {
ids = ImmutableList.copyOf(Iterables.transform(cursor, new Function<DBObject, String>() {
@Override
public String apply(@Nullable DBObject input) {
return (String) input.get(Document.ID);
}
}));
} finally {
cursor.close();
}
StringBuilder sb = new StringBuilder("Split documents with following ids were deleted as part of GC \n");
Joiner.on(StandardSystemProperty.LINE_SEPARATOR.value()).appendTo(sb, ids);
log.debug(sb.toString());
}
示例10: loginFromKeytab
import com.google.common.base.StandardSystemProperty; //导入依赖的package包/类
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");
}
}
}
示例11: getKmsUrl
import com.google.common.base.StandardSystemProperty; //导入依赖的package包/类
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()));
}
}
}
示例12: createTempDir
import com.google.common.base.StandardSystemProperty; //导入依赖的package包/类
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) + ')');
}
示例13: runViewer
import com.google.common.base.StandardSystemProperty; //导入依赖的package包/类
static void runViewer(Directories directories) throws InterruptedException {
// initLogging() already called by OfflineViewer.main()
checkNotNull(startupLogger);
String version;
try {
version = Version.getVersion(MainEntryPoint.class);
startupLogger.info("Glowroot version: {}", version);
startupLogger.info("Java version: {}", StandardSystemProperty.JAVA_VERSION.value());
ImmutableMap<String, String> properties =
getGlowrootProperties(directories.getConfDir(), directories.getSharedConfDir());
new EmbeddedGlowrootAgentInit(directories.getDataDir(), true)
.init(directories.getPluginsDir(), directories.getConfDir(),
directories.getSharedConfDir(), directories.getLogDir(),
directories.getTmpDir(), directories.getGlowrootJarFile(), properties,
null, version);
} catch (AgentDirsLockedException e) {
logAgentDirsLockedException(directories.getConfDir(), e.getLockFile());
return;
} catch (Throwable t) {
startupLogger.error("Glowroot cannot start: {}", t.getMessage(), t);
return;
}
// Glowroot does not create any non-daemon threads, so need to block jvm from exiting when
// running the viewer
Thread.sleep(Long.MAX_VALUE);
}
示例14: start
import com.google.common.base.StandardSystemProperty; //导入依赖的package包/类
@RequiresNonNull("startupLogger")
private static void start(Directories directories, Map<String, String> properties,
@Nullable Instrumentation instrumentation) throws Exception {
ManagementFactory.getThreadMXBean().setThreadCpuTimeEnabled(true);
ManagementFactory.getThreadMXBean().setThreadContentionMonitoringEnabled(true);
String version = Version.getVersion(MainEntryPoint.class);
startupLogger.info("Glowroot version: {}", version);
startupLogger.info("Java version: {}", StandardSystemProperty.JAVA_VERSION.value());
String collectorAddress = properties.get("glowroot.collector.address");
Collector customCollector = loadCustomCollector(directories.getGlowrootDir());
if (Strings.isNullOrEmpty(collectorAddress) && customCollector == null) {
glowrootAgentInit = new EmbeddedGlowrootAgentInit(directories.getDataDir(), false);
} else {
if (customCollector != null) {
startupLogger.info("using collector: {}", customCollector.getClass().getName());
}
String collectorAuthority = properties.get("glowroot.collector.authority");
glowrootAgentInit = new NonEmbeddedGlowrootAgentInit(collectorAddress,
collectorAuthority, customCollector);
}
glowrootAgentInit.init(directories.getPluginsDir(), directories.getConfDir(),
directories.getSharedConfDir(), directories.getLogDir(), directories.getTmpDir(),
directories.getGlowrootJarFile(), properties, instrumentation, version);
}
示例15: createJavaInfo
import com.google.common.base.StandardSystemProperty; //导入依赖的package包/类
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(SystemProperties.maskJvmArgs(runtimeMXBean.getInputArguments(),
jvmConfig.maskSystemProperties()))
.setHeapDumpDefaultDir(heapDumpPath)
.setGlowrootAgentVersion(glowrootVersion)
.build();
}