Example usage for java.time Duration ofSeconds

List of usage examples for java.time Duration ofSeconds

Introduction

In this page you can find the example usage for java.time Duration ofSeconds.

Prototype

public static Duration ofSeconds(long seconds) 

Source Link

Document

Obtains a Duration representing a number of seconds.

Usage

From source file:org.apache.zeppelin.cluster.ClusterManagerServer.java

public void unicastClusterEvent(String host, int port, String msg) {
    LOGGER.info("send unicastClusterEvent message {}", msg);

    Address address = Address.from(host, port);
    CompletableFuture<byte[]> response = messagingService.sendAndReceive(address, ZEPL_CLUSTER_EVENT_TOPIC,
            msg.getBytes(), Duration.ofSeconds(2));
    response.whenComplete((r, e) -> {
        if (null == e) {
            LOGGER.error(e.getMessage(), e);
        } else {//from  w  w  w.j a v  a2  s.c  om
            LOGGER.info("unicastClusterEvent success! {}", msg);
        }
    });
}

From source file:org.apache.zeppelin.cluster.ClusterManagerServer.java

public void broadcastClusterEvent(String msg) {
    LOGGER.info("send broadcastClusterEvent message {}", msg);

    for (Node node : clusterNodes) {
        if (StringUtils.equals(node.address().host(), zeplServerHost)
                && node.address().port() == raftServerPort) {
            // skip myself
            continue;
        }//from  w  ww. java  2  s.c o m

        CompletableFuture<byte[]> response = messagingService.sendAndReceive(node.address(),
                ZEPL_CLUSTER_EVENT_TOPIC, msg.getBytes(), Duration.ofSeconds(2));
        response.whenComplete((r, e) -> {
            if (null == e) {
                LOGGER.error(e.getMessage(), e);
            } else {
                LOGGER.info("broadcastClusterNoteEvent success! {}", msg);
            }
        });
    }
}

From source file:org.cloudfoundry.client.ApplicationsTest.java

private static Mono<String> waitForStaging(CloudFoundryClient cloudFoundryClient, String applicationId) {
    return cloudFoundryClient.applicationsV2()
            .get(GetApplicationRequest.builder().applicationId(applicationId).build())
            .map(response -> response.getEntity().getPackageState()).where("STAGED"::equals)
            .repeatWhenEmpty(10, DelayUtils.exponentialBackOff(Duration.ofSeconds(1), Duration.ofSeconds(10)))
            .map(state -> applicationId);
}

From source file:org.cloudfoundry.client.ApplicationsTest.java

private static Mono<String> waitForStarting(CloudFoundryClient cloudFoundryClient, String applicationId) {
    return cloudFoundryClient.applicationsV2()
            .instances(ApplicationInstancesRequest.builder().applicationId(applicationId).build())
            .flatMap(response -> Flux.fromIterable(response.values()))
            .filter(applicationInstanceInfo -> "RUNNING".equals(applicationInstanceInfo.getState())).next()
            .repeatWhenEmpty(10, DelayUtils.exponentialBackOff(Duration.ofSeconds(1), Duration.ofSeconds(10)))
            .map(info -> applicationId);
}

From source file:org.cloudfoundry.client.v2.ApplicationsTest.java

private static Mono<ApplicationInstanceInfo> waitForInstanceRestart(CloudFoundryClient cloudFoundryClient,
        String applicationId, String instanceName, Optional<Double> optionalSince) {
    return getInstanceInfo(cloudFoundryClient, applicationId, instanceName)
            .filter(info -> !isIdentical(info.getSince(), optionalSince.orElse(null)))
            .repeatWhenEmpty(DelayUtils.exponentialBackOff(Duration.ofSeconds(1), Duration.ofSeconds(15),
                    Duration.ofMinutes(5)));
}

From source file:org.cloudfoundry.client.v2.ApplicationsTest.java

private static Mono<AbstractApplicationResource> waitForStagingApplication(
        CloudFoundryClient cloudFoundryClient, String applicationId) {
    return requestGetApplication(cloudFoundryClient, applicationId)
            .filter(response -> "STAGED".equals(response.getEntity().getPackageState()))
            .repeatWhenEmpty(DelayUtils.exponentialBackOff(Duration.ofSeconds(1), Duration.ofSeconds(15),
                    Duration.ofMinutes(5)));
}

From source file:org.cloudfoundry.client.v2.ApplicationsTest.java

private static Mono<ApplicationInstanceInfo> waitForStartingInstanceInfo(CloudFoundryClient cloudFoundryClient,
        String applicationId) {/*from w ww . j  a  v a  2  s .c  om*/
    return cloudFoundryClient.applicationsV2()
            .instances(ApplicationInstancesRequest.builder().applicationId(applicationId).build())
            .flatMap(response -> Flux.fromIterable(response.getInstances().values()))
            .filter(applicationInstanceInfo -> "RUNNING".equals(applicationInstanceInfo.getState())).next()
            .repeatWhenEmpty(DelayUtils.exponentialBackOff(Duration.ofSeconds(1), Duration.ofSeconds(15),
                    Duration.ofMinutes(5)));
}

From source file:org.cloudfoundry.reactor.uaa.identityproviders.ReactorIdentityProvidersTest.java

@Test
public void createLdap() {
    mockRequest(InteractionContext.builder()
            .request(TestRequest.builder().method(POST).path("/identity-providers?rawConfig=true")
                    .header("X-Identity-Zone-Id", "test-identity-zone-id")
                    .payload("fixtures/uaa/identity-providers/POST_request_ldap.json").build())
            .response(TestResponse.builder().status(CREATED)
                    .payload("fixtures/uaa/identity-providers/POST_response_ldap.json").build())
            .build());// ww w .  j av  a 2s.  co  m

    this.identityProviders
            .create(CreateIdentityProviderRequest.builder().active(true)
                    .configuration(LdapConfiguration.builder()
                            .attributeMappings(AttributeMappings.builder().build())
                            .ldapProfileFile(LdapProfileFile.SIMPLE_BIND).ldapGroupFile(LdapGroupFile.NO_GROUP)
                            .baseUrl("ldap://localhost:33389").skipSSLVerification(false)
                            .mailAttributeName("mail").mailSubstituteOverridesLdap(false).build())
                    .name("ldap name").originKey("ldap").type(Type.LDAP).identityZoneId("test-identity-zone-id")
                    .build())
            .as(StepVerifier::create)
            .expectNext(
                    CreateIdentityProviderResponse.builder().active(true).createdAt(1465001967988L)
                            .configuration(LdapConfiguration.builder()
                                    .attributeMappings(AttributeMappings.builder().build()).autoAddGroups(true)
                                    .baseUrl("ldap://localhost:33389")
                                    .externalGroupsWhitelist(Collections.emptyList()).groupSearchDepthLimit(10)
                                    .groupSearchSubTree(true).ldapProfileFile(LdapProfileFile.SIMPLE_BIND)
                                    .ldapGroupFile(LdapGroupFile.NO_GROUP).mailAttributeName("mail")
                                    .mailSubstituteOverridesLdap(false).skipSSLVerification(false)
                                    .userDistinguishedNamePattern("cn={0},ou=Users,dc=test,dc=com")
                                    .userDistinguishedNamePatternDelimiter(";").build())
                            .id("aaccbccb-1c85-4e8b-86ed-4ce66f91c856").identityZoneId("uaa")
                            .lastModified(1465001967988L).name("ldap name").originKey("ldap").type(Type.LDAP)
                            .version(0).build())
            .expectComplete().verify(Duration.ofSeconds(5));
}

From source file:org.cloudfoundry.reactor.uaa.identityproviders.ReactorIdentityProvidersTest.java

@Test
public void createOauth() {
    mockRequest(InteractionContext.builder()
            .request(TestRequest.builder().method(POST).path("/identity-providers?rawConfig=true")
                    .header("X-Identity-Zone-Id", "test-identity-zone-id")
                    .payload("fixtures/uaa/identity-providers/POST_request_oauth.json").build())
            .response(TestResponse.builder().status(CREATED)
                    .payload("fixtures/uaa/identity-providers/POST_response_oauth.json").build())
            .build());/*from w  w w  . jav a 2 s .  c o m*/

    this.identityProviders
            .create(CreateIdentityProviderRequest.builder().active(true)
                    .configuration(OAuth2Configuration.builder()
                            .attributeMappings(AttributeMappings.builder().build()).authUrl("http://auth.url")
                            .tokenUrl("http://token.url").tokenKey("token-key").showLinkText(false)
                            .skipSslVerification(false).relyingPartyId("uaa").relyingPartySecret("secret")
                            .addShadowUserOnLogin(true).build())
                    .name("UAA Provider").originKey("oauth2.0").type(Type.OAUTH2)
                    .identityZoneId("test-identity-zone-id").build())
            .as(StepVerifier::create)
            .expectNext(
                    CreateIdentityProviderResponse.builder().active(true).createdAt(1465001966855L)
                            .configuration(OAuth2Configuration.builder()
                                    .attributeMappings(AttributeMappings.builder().build())
                                    .authUrl("http://auth.url").externalGroupsWhitelist(Collections.emptyList())
                                    .tokenUrl("http://token.url").tokenKey("token-key").showLinkText(false)
                                    .skipSslVerification(false).relyingPartyId("uaa")
                                    .relyingPartySecret("secret").addShadowUserOnLogin(true).build())
                            .id("16506900-561d-411f-904b-15c3e2722cba").identityZoneId("uaa")
                            .lastModified(1465001966855L).name("UAA Provider").originKey("oauth2.0")
                            .type(Type.OAUTH2).version(0).build())
            .expectComplete().verify(Duration.ofSeconds(5));
}

From source file:org.cloudfoundry.reactor.uaa.identityproviders.ReactorIdentityProvidersTest.java

@Test
public void createSaml() {
    mockRequest(InteractionContext.builder()
            .request(TestRequest.builder().method(POST).path("/identity-providers?rawConfig=true")
                    .header("X-Identity-Zone-Id", "test-identity-zone-id")
                    .payload("fixtures/uaa/identity-providers/POST_request_saml.json").build())
            .response(TestResponse.builder().status(CREATED)
                    .payload("fixtures/uaa/identity-providers/POST_response_saml.json").build())
            .build());//from ww w.java2 s.co m

    this.identityProviders
            .create(CreateIdentityProviderRequest.builder().active(true).configuration(SamlConfiguration
                    .builder().addShadowUserOnLogin(true).assertionConsumerIndex(0)
                    .attributeMappings(AttributeMappings.builder().build())
                    .groupMappingMode(ExternalGroupMappingMode.EXPLICITLY_MAPPED)
                    .linkText("IDPEndpointsMockTests Saml Provider:SAML")
                    .metaDataLocation(
                            "<?xml version=\"1.0\" encoding=\"UTF-8\"?><md:EntityDescriptor xmlns:md=\"urn:oasis:names:tc:SAML:2.0:metadata\" entityID=\"http://www.okta"
                                    + ".com/SAML\"><md:IDPSSODescriptor WantAuthnRequestsSigned=\"true\" protocolSupportEnumeration=\"urn:oasis:names:tc:SAML:2.0:protocol\"><md:KeyDescriptor "
                                    + "use=\"signing\"><ds:KeyInfo xmlns:ds=\"http://www.w3"
                                    + ".org/2000/09/xmldsig#\"><ds:X509Data><ds:X509Certificate>MIICmTCCAgKgAwIBAgIGAUPATqmEMA0GCSqGSIb3DQEBBQUAMIGPMQswCQYDVQQGEwJVUzETMBEG"
                                    + "\nA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2FuIEZyYW5jaXNjbzENMAsGA1UECgwET2t0YTEU\nMBIGA1UECwwLU1NPUHJvdmlkZXIxEDAOBgNVBAMMB1Bpdm90YWwxHDAaBgkqhkiG9w0BCQEWDWlu"
                                    + "\nZm9Ab2t0YS5jb20wHhcNMTQwMTIzMTgxMjM3WhcNNDQwMTIzMTgxMzM3WjCBjzELMAkGA1UEBhMC\nVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDVNhbiBGcmFuY2lzY28xDTALBgNVBAoM"
                                    + "\nBE9rdGExFDASBgNVBAsMC1NTT1Byb3ZpZGVyMRAwDgYDVQQDDAdQaXZvdGFsMRwwGgYJKoZIhvcN\nAQkBFg1pbmZvQG9rdGEuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCeil67/TLOiTZU"
                                    + "\nWWgW2XEGgFZ94bVO90v5J1XmcHMwL8v5Z/8qjdZLpGdwI7Ph0CyXMMNklpaR/Ljb8fsls3amdT5O\nBw92Zo8ulcpjw2wuezTwL0eC0wY/GQDAZiXL59npE6U+fH1lbJIq92hx0HJSru/0O1q3+A/+jjZL\n3tL"
                                    + "/SwIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAI5BoWZoH6Mz9vhypZPOJCEKa/K+biZQsA4Zqsuk\nvvphhSERhqk/Nv76Vkl8uvJwwHbQrR9KJx4L3PRkGCG24rix71jEuXVGZUsDNM3CUKnARx4MEab6\nGFHNkZ6DmoT"
                                    + "/PFagngecHu+EwmuDtaG0rEkFrARwe+d8Ru0BN558abFb</ds:X509Certificate></ds:X509Data></ds:KeyInfo></md:KeyDescriptor><md:NameIDFormat>urn:oasis:names:tc:SAML:1"
                                    + ".1:nameid-format:emailAddress</md:NameIDFormat><md:NameIDFormat>urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified</md:NameIDFormat><md:SingleSignOnService "
                                    + "Binding=\"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST\" Location=\"https://pivotal.oktapreview"
                                    + ".com/app/pivotal_pivotalcfstaging_1/k2lw4l5bPODCMIIDBRYZ/sso/saml\"/><md:SingleSignOnService Binding=\"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect\" "
                                    + "Location=\"https://pivotal.oktapreview.com/app/pivotal_pivotalcfstaging_1/k2lw4l5bPODCMIIDBRYZ/sso/saml\"/></md:IDPSSODescriptor></md:EntityDescriptor>\n")
                    .metadataTrustCheck(false).nameId("urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress")
                    .showSamlLink(false)
                    .socketFactoryClassName(
                            "org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory")
                    .build()).name("SAML name").originKey("SAML").type(Type.SAML)
                    .identityZoneId("test-identity-zone-id").build())
            .as(StepVerifier::create)
            .expectNext(CreateIdentityProviderResponse.builder().active(true).createdAt(1465001965526L)
                    .configuration(SamlConfiguration.builder().addShadowUserOnLogin(true)
                            .assertionConsumerIndex(0).attributeMappings(AttributeMappings.builder().build())
                            .externalGroupsWhitelist(Collections.emptyList())
                            .groupMappingMode(ExternalGroupMappingMode.EXPLICITLY_MAPPED).idpEntityAlias("SAML")
                            .linkText("IDPEndpointsMockTests Saml Provider:SAML")
                            .metaDataLocation(
                                    "<?xml version=\"1.0\" encoding=\"UTF-8\"?><md:EntityDescriptor xmlns:md=\"urn:oasis:names:tc:SAML:2.0:metadata\" entityID=\"http://www.okta"
                                            + ".com/SAML\"><md:IDPSSODescriptor WantAuthnRequestsSigned=\"true\" protocolSupportEnumeration=\"urn:oasis:names:tc:SAML:2.0:protocol\"><md:KeyDescriptor "
                                            + "use=\"signing\"><ds:KeyInfo xmlns:ds=\"http://www.w3"
                                            + ".org/2000/09/xmldsig#\"><ds:X509Data><ds:X509Certificate>MIICmTCCAgKgAwIBAgIGAUPATqmEMA0GCSqGSIb3DQEBBQUAMIGPMQswCQYDVQQGEwJVUzETMBEG"
                                            + "\nA1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2FuIEZyYW5jaXNjbzENMAsGA1UECgwET2t0YTEU\nMBIGA1UECwwLU1NPUHJvdmlkZXIxEDAOBgNVBAMMB1Bpdm90YWwxHDAaBgkqhkiG9w0BCQEWDWlu"
                                            + "\nZm9Ab2t0YS5jb20wHhcNMTQwMTIzMTgxMjM3WhcNNDQwMTIzMTgxMzM3WjCBjzELMAkGA1UEBhMC\nVVMxEzARBgNVBAgMCkNhbGlmb3JuaWExFjAUBgNVBAcMDVNhbiBGcmFuY2lzY28xDTALBgNVBAoM"
                                            + "\nBE9rdGExFDASBgNVBAsMC1NTT1Byb3ZpZGVyMRAwDgYDVQQDDAdQaXZvdGFsMRwwGgYJKoZIhvcN\nAQkBFg1pbmZvQG9rdGEuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCeil67/TLOiTZU"
                                            + "\nWWgW2XEGgFZ94bVO90v5J1XmcHMwL8v5Z/8qjdZLpGdwI7Ph0CyXMMNklpaR/Ljb8fsls3amdT5O\nBw92Zo8ulcpjw2wuezTwL0eC0wY/GQDAZiXL59npE6U+fH1lbJIq92hx0HJSru/0O1q3+A/+jjZL\n3tL"
                                            + "/SwIDAQABMA0GCSqGSIb3DQEBBQUAA4GBAI5BoWZoH6Mz9vhypZPOJCEKa/K+biZQsA4Zqsuk\nvvphhSERhqk/Nv76Vkl8uvJwwHbQrR9KJx4L3PRkGCG24rix71jEuXVGZUsDNM3CUKnARx4MEab6\nGFHNkZ6DmoT"
                                            + "/PFagngecHu+EwmuDtaG0rEkFrARwe+d8Ru0BN558abFb</ds:X509Certificate></ds:X509Data></ds:KeyInfo></md:KeyDescriptor><md:NameIDFormat>urn:oasis:names:tc:SAML:1"
                                            + ".1:nameid-format:emailAddress</md:NameIDFormat><md:NameIDFormat>urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified</md:NameIDFormat><md:SingleSignOnService "
                                            + "Binding=\"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST\" Location=\"https://pivotal.oktapreview"
                                            + ".com/app/pivotal_pivotalcfstaging_1/k2lw4l5bPODCMIIDBRYZ/sso/saml\"/><md:SingleSignOnService Binding=\"urn:oasis:names:tc:SAML:2.0:bindings:HTTP-Redirect\" "
                                            + "Location=\"https://pivotal.oktapreview.com/app/pivotal_pivotalcfstaging_1/k2lw4l5bPODCMIIDBRYZ/sso/saml\"/></md:IDPSSODescriptor></md:EntityDescriptor>\n")
                            .metadataTrustCheck(false)
                            .nameId("urn:oasis:names:tc:SAML:1.1:nameid-format:emailAddress")
                            .showSamlLink(false)
                            .socketFactoryClassName(
                                    "org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory")
                            .zoneId("uaa").build())
                    .id("a2e96056-c777-40b8-95b8-ff81b441fcf1").identityZoneId("uaa")
                    .lastModified(1465001965526L).name("SAML name").originKey("SAML").type(Type.SAML).version(0)
                    .build())
            .expectComplete().verify(Duration.ofSeconds(5));
}