Search in sources :

Example 6 with ZTSClientException

use of com.yahoo.athenz.zts.ZTSClientException in project athenz by yahoo.

the class PolicyUpdater method postDomainMetrics.

public static void postDomainMetrics(ZTSClient zts) {
    final String filepath = getFilePath();
    File dir = new File(filepath);
    File[] filenames = dir.listFiles();
    if (filenames == null) {
        return;
    }
    for (int i = 0; i < filenames.length; i++) {
        String domainName = filenames[i].getName().split("_")[0];
        DomainMetrics domainMetrics = null;
        final String metricFile = filepath + filenames[i].getName();
        try {
            Path path = Paths.get(metricFile);
            domainMetrics = JSON.fromBytes(Files.readAllBytes(path), DomainMetrics.class);
            zts.postDomainMetrics(domainName, domainMetrics);
            Files.deleteIfExists(path);
        } catch (ZTSClientException | IOException ex) {
            LOG.error("Unable to push domain metrics from {} - error: {}", metricFile, ex.getMessage());
        }
    }
}
Also used : Path(java.nio.file.Path) DomainMetrics(com.yahoo.athenz.zts.DomainMetrics) ZTSClientException(com.yahoo.athenz.zts.ZTSClientException) IOException(java.io.IOException) File(java.io.File)

Aggregations

ZTSClientException (com.yahoo.athenz.zts.ZTSClientException)6 ZTSClient (com.yahoo.athenz.zts.ZTSClient)3 File (java.io.File)3 CommandLine (org.apache.commons.cli.CommandLine)3 InstanceIdentity (com.yahoo.athenz.zts.InstanceIdentity)2 PublicKeyEntry (com.yahoo.athenz.zts.PublicKeyEntry)2 IOException (java.io.IOException)2 Path (java.nio.file.Path)2 PrivateKey (java.security.PrivateKey)2 DERIA5String (org.bouncycastle.asn1.DERIA5String)2 AWSCredentials (com.amazonaws.auth.AWSCredentials)1 KeyRefresher (com.oath.auth.KeyRefresher)1 DomainMetrics (com.yahoo.athenz.zts.DomainMetrics)1 InstanceRefreshInformation (com.yahoo.athenz.zts.InstanceRefreshInformation)1 InstanceRegisterInformation (com.yahoo.athenz.zts.InstanceRegisterInformation)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 List (java.util.List)1 SSLContext (javax.net.ssl.SSLContext)1 ParseException (org.apache.commons.cli.ParseException)1