本文整理了Java中org.datatransferproject.api.launcher.Monitor
类的一些代码示例,展示了Monitor
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Monitor
类的具体详情如下:
包路径:org.datatransferproject.api.launcher.Monitor
类名称:Monitor
[英]The system monitoring and logging interface which can be obtained either via injection or from ExtensionContext#getMonitor().
Implementations are responsible for processing and forwarding events to an external sink or service.
[中]系统监控和日志记录界面,可通过注入或从ExtensionContext#getMonitor()获取。
实现负责处理事件并将其转发到外部接收器或服务。
代码示例来源:origin: google/data-transfer-project
@Override
public void info(Supplier<String> supplier, Object... data) {
for (Monitor delegate : delegates) {
delegate.info(supplier, data);
}
}
代码示例来源:origin: google/data-transfer-project
@Override
public void severe(Supplier<String> supplier, Object... data) {
for (Monitor delegate : delegates) {
delegate.severe(supplier, data);
}
}
代码示例来源:origin: google/data-transfer-project
@Override
public void debug(Supplier<String> supplier, Object... data) {
for (Monitor delegate : delegates) {
delegate.debug(supplier, data);
}
}
}
代码示例来源:origin: google/data-transfer-project
/** Starts the api server, currently the reference implementation. */
public static void main(String[] args) {
Monitor monitor = loadMonitor();
monitor.info(() -> "Starting API Server.");
Thread.setDefaultUncaughtExceptionHandler(
(thread, t) ->
monitor.severe(() -> "Uncaught exception in thread: " + thread.getName(), t));
ApiMain apiMain = new ApiMain(monitor);
apiMain.initializeHttp();
apiMain.start();
}
代码示例来源:origin: google/data-transfer-project
@Override
public void initialize(ExtensionContext context) {
Monitor monitor = context.getMonitor();
monitor.debug(() -> "Starting Twitter initialization");
if (initialized) {
monitor.severe(() -> "TwitterTransferExtension already initialized.");
return;
}
AppCredentials appCredentials;
try {
appCredentials =
context
.getService(AppCredentialStore.class)
.getAppCredentials(TWITTER_KEY, TWITTER_SECRET);
} catch (IOException e) {
monitor.info(
() ->
format(
"Unable to retrieve Twitter AppCredentials. Did you set %s and %s?",
TWITTER_KEY, TWITTER_SECRET),
e);
return;
}
exporter = new TwitterPhotosExporter(appCredentials, monitor);
importer = new TwitterPhotosImporter(appCredentials, monitor);
initialized = true;
}
}
代码示例来源:origin: google/data-transfer-project
PortabilityJob job = store.findJob(jobId);
if (job == null) {
monitor.debug(
() -> format("Could not poll job %s, it was not present in the key-value store", jobId));
} else if (job.jobAuthorization().state() == JobAuthorization.State.CREDS_STORED) {
monitor.debug(() -> format("Polled job %s in state CREDS_STORED", jobId));
JobAuthorization jobAuthorization = job.jobAuthorization();
if (!Strings.isNullOrEmpty(jobAuthorization.encryptedAuthData())) {
monitor.debug(
() -> format("Polled job %s has auth data as expected. Done polling.", jobId));
} else {
monitor.severe(
() ->
format(
monitor.debug(
() ->
format(
代码示例来源:origin: google/data-transfer-project
Monitor monitor = context.getMonitor();
if (initialized) {
monitor.severe(() -> "SmugMugTransferExtension already initailized.");
return;
.getAppCredentials(SMUGMUG_KEY, SMUGMUG_SECRET);
} catch (IOException e) {
monitor.info(
() ->
format(
代码示例来源:origin: google/data-transfer-project
boolean success = false;
UUID jobId = JobMetadata.getJobId();
monitor.debug(() -> format("Begin processing jobId: %s", jobId));
hooks.jobStarted(jobId);
monitor.debug(
() ->
format(
AuthDataDecryptService decryptService = getAuthDecryptService(scheme);
if (decryptService == null) {
monitor.severe(
() ->
format(
monitor.debug(() -> "Finished copy for jobId: " + jobId);
success = true;
} catch (IOException | SecurityException | CopyException e) {
monitor.severe(() -> "Error processing jobId: " + jobId, e);
} finally {
monitor.debug(() -> "Finished processing jobId: " + jobId);
markJobFinished(jobId, success);
hooks.jobFinished(jobId, success);
代码示例来源:origin: google/data-transfer-project
@Override
public PublicKey parse(byte[] encoded) {
KeyFactory factory;
try {
factory = KeyFactory.getInstance(ALGORITHM);
return factory.generatePublic(new X509EncodedKeySpec(encoded));
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
monitor.severe(() -> "Error parsing public key for: " + ALGORITHM, e);
throw new RuntimeException("InvalidKeySpecException generating key", e);
}
}
}
代码示例来源:origin: google/data-transfer-project
public void debug(String msg, Throwable thrown) {
DELEGATE.info(() -> msg, thrown);
}
代码示例来源:origin: google/data-transfer-project
folders.add(new BlobbyStorageContainerResource(file.getName(), file.getId(), null, null));
} else if (FUSION_TABLE_MIME_TYPE.equals(file.getMimeType())) {
monitor.info(() -> "Exporting of fusion tables is not yet supported: " + file);
} else if (MAP_MIME_TYPE.equals(file.getMimeType())) {
monitor.info(() -> "Exporting of maps is not yet supported: " + file);
} else {
try {
file.getId()));
} catch (Exception e) {
monitor.severe(() -> "Error exporting " + file, e);
monitor.info(() -> "Exported " + file);
代码示例来源:origin: google/data-transfer-project
public void debug(String msg, long value) {
DELEGATE.debug(() -> msg);
}
代码示例来源:origin: google/data-transfer-project
monitor.debug(() -> "A public key cannot be persisted again");
return false;
PublicKeySerializer keySerializer = getPublicKeySerializer(scheme);
if (keySerializer == null) {
monitor.severe(
() ->
format(
previous.jobAuthorization().state() == JobAuthorization.State.CREDS_AVAILABLE));
} catch (IllegalStateException | IOException e) {
monitor.debug(
() ->
format(
代码示例来源:origin: google/data-transfer-project
@Override
public SecretKey generate() {
try {
KeyGenerator generator = KeyGenerator.getInstance(ALGORITHM);
return generator.generateKey();
} catch (NoSuchAlgorithmException e) {
monitor.severe(() -> "NoSuchAlgorithmException for: " + ALGORITHM, e);
throw new RuntimeException("Error creating key generator", e);
}
}
代码示例来源:origin: google/data-transfer-project
public void info(String msg, Object... args) {
DELEGATE.info(() -> msg);
}
代码示例来源:origin: google/data-transfer-project
public void debug(String msg, Object... args) {
DELEGATE.debug(() -> msg);
}
代码示例来源:origin: google/data-transfer-project
@Override
public KeyPair generate() {
KeyPairGenerator kpg = null;
try {
kpg = KeyPairGenerator.getInstance(ALGORITHM);
} catch (NoSuchAlgorithmException e) {
monitor.severe(() -> "NoSuchAlgorithmException for: " + ALGORITHM, e);
throw new RuntimeException("NoSuchAlgorithmException generating key", e);
}
kpg.initialize(1024);
return kpg.genKeyPair();
}
代码示例来源:origin: google/data-transfer-project
public void warn(String msg, Throwable thrown) {
DELEGATE.info(() -> msg, thrown);
}
代码示例来源:origin: google/data-transfer-project
public void debug(Throwable thrown) {
DELEGATE.debug(() -> "Error processing request", thrown);
}
代码示例来源:origin: google/data-transfer-project
@Override
public String decrypt(String encrypted) {
try {
byte[] decoded = BaseEncoding.base64Url().decode(encrypted);
Cipher cipher = Cipher.getInstance(transformation);
cipher.init(Cipher.DECRYPT_MODE, key);
byte[] decrypted = cipher.doFinal(decoded);
if (decrypted == null || decrypted.length <= 8) {
throw new RuntimeException("incorrect decrypted text.");
}
byte[] data = new byte[decrypted.length - 8];
System.arraycopy(decrypted, 8, data, 0, data.length);
return new String(data, Charsets.UTF_8);
} catch (BadPaddingException
| IllegalBlockSizeException
| InvalidKeyException
| NoSuchAlgorithmException
| NoSuchPaddingException e) {
monitor.severe(() -> format("Error decrypting data, length: %s", encrypted.length()), e);
throw new RuntimeException(e);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!