@Test @Ignore public void testSiwftKeystoneV3() throws Exception { StorageConfiguration conf = new StorageConfiguration(); conf.setProvider("openstack-swift-v3"); conf.setSwiftKeystoneAuthUrl("http: conf.setSwiftDomain("default"); conf.setSwiftProjectName("demo"); conf.setSwiftUser("admin"); conf.setSwiftPassword("nomoresecret"); SwiftKeystoneFactoryV3 v3 = new SwiftKeystoneFactoryV3(conf); OSClient.OSClientV3 client = v3.get(); System.err.println(client.objectStorage().containers().list()); client.objectStorage().containers().create("paris"); System.err.println(client.objectStorage().containers().list()); client.objectStorage().objects().put("paris", "paris", Payloads.create(new File("/home/youdsys/Downloads/consistency error.zip"))); System.err.println(client.objectStorage().objects().list("paris")); }
public OSClient.OSClientV3 get() { Token currentToken = atomicToken.get(); Date nearTime = LocalDateUtil.getDate(LocalDateUtil.now().plusSeconds(configuration.getSwiftHardRenewTokenDelayBeforeExpireTime())); if (currentToken == null || currentToken.getExpires().before(nearTime)) { synchronized (monitor) { currentToken = atomicToken.get(); if (currentToken == null) { OSClient.OSClientV3 osClientV3 = renewToken(); currentToken = osClientV3.getToken(); atomicToken.set(currentToken); return osClientV3; } } } Date farTime = LocalDateUtil.getDate(LocalDateUtil.now().plusSeconds(configuration.getSwiftSoftRenewTokenDelayBeforeExpireTime())); if (currentToken.getExpires().before(farTime)) { if (oneThread.compareAndSet(true, false)) { try { OSClient.OSClientV3 osClientV3 = renewToken(); currentToken = osClientV3.getToken(); atomicToken.set(currentToken); return osClientV3; } finally { oneThread.set(true); } } } OSClientSession.OSClientSessionV3 currentClient = (OSClientSession.OSClientSessionV3) OSClientSession.OSClientSessionV3.getCurrent(); if (null != currentClient && currentToken.equals(currentClient.getToken())) { return currentClient; } return OSFactory.clientFromToken(currentToken, configOS4J); }
SwiftKeystoneFactoryV3 implements Supplier<OSClient> { public OSClient.OSClientV3 get() { Token currentToken = atomicToken.get(); Date nearTime = LocalDateUtil.getDate(LocalDateUtil.now().plusSeconds(configuration.getSwiftHardRenewTokenDelayBeforeExpireTime())); if (currentToken == null || currentToken.getExpires().before(nearTime)) { synchronized (monitor) { currentToken = atomicToken.get(); if (currentToken == null) { OSClient.OSClientV3 osClientV3 = renewToken(); currentToken = osClientV3.getToken(); atomicToken.set(currentToken); return osClientV3; } } } Date farTime = LocalDateUtil.getDate(LocalDateUtil.now().plusSeconds(configuration.getSwiftSoftRenewTokenDelayBeforeExpireTime())); if (currentToken.getExpires().before(farTime)) { if (oneThread.compareAndSet(true, false)) { try { OSClient.OSClientV3 osClientV3 = renewToken(); currentToken = osClientV3.getToken(); atomicToken.set(currentToken); return osClientV3; } finally { oneThread.set(true); } } } OSClientSession.OSClientSessionV3 currentClient = (OSClientSession.OSClientSessionV3) OSClientSession.OSClientSessionV3.getCurrent(); if (null != currentClient && currentToken.equals(currentClient.getToken())) { return currentClient; } return OSFactory.clientFromToken(currentToken, configOS4J); } }
SwiftKeystoneFactoryV3 implements Supplier<OSClient> { public OSClient.OSClientV3 get() { Token currentToken = atomicToken.get(); Date nearTime = LocalDateUtil.getDate(LocalDateUtil.now().plusSeconds(configuration.getSwiftHardRenewTokenDelayBeforeExpireTime())); if (currentToken == null || currentToken.getExpires().before(nearTime)) { synchronized (monitor) { currentToken = atomicToken.get(); if (currentToken == null) { OSClient.OSClientV3 osClientV3 = renewToken(); currentToken = osClientV3.getToken(); atomicToken.set(currentToken); return osClientV3; } } } Date farTime = LocalDateUtil.getDate(LocalDateUtil.now().plusSeconds(configuration.getSwiftSoftRenewTokenDelayBeforeExpireTime())); if (currentToken.getExpires().before(farTime)) { if (oneThread.compareAndSet(true, false)) { try { OSClient.OSClientV3 osClientV3 = renewToken(); currentToken = osClientV3.getToken(); atomicToken.set(currentToken); return osClientV3; } finally { oneThread.set(true); } } } OSClientSession.OSClientSessionV3 currentClient = (OSClientSession.OSClientSessionV3) OSClientSession.OSClientSessionV3.getCurrent(); if (null != currentClient && currentToken.equals(currentClient.getToken())) { return currentClient; } return OSFactory.clientFromToken(currentToken, configOS4J); } SwiftKeystoneFactoryV3(StorageConfiguration configuration); }
SwiftKeystoneFactoryV3 implements Supplier<OSClient> { public OSClient.OSClientV3 get() { Token currentToken = atomicToken.get(); Date nearTime = LocalDateUtil.getDate(LocalDateUtil.now().plusSeconds(configuration.getSwiftHardRenewTokenDelayBeforeExpireTime())); if (currentToken == null || currentToken.getExpires().before(nearTime)) { synchronized (monitor) { currentToken = atomicToken.get(); if (currentToken == null) { OSClient.OSClientV3 osClientV3 = renewToken(); currentToken = osClientV3.getToken(); atomicToken.set(currentToken); return osClientV3; } } } Date farTime = LocalDateUtil.getDate(LocalDateUtil.now().plusSeconds(configuration.getSwiftSoftRenewTokenDelayBeforeExpireTime())); if (currentToken.getExpires().before(farTime)) { if (oneThread.compareAndSet(true, false)) { try { OSClient.OSClientV3 osClientV3 = renewToken(); currentToken = osClientV3.getToken(); atomicToken.set(currentToken); return osClientV3; } finally { oneThread.set(true); } } } OSClientSession.OSClientSessionV3 currentClient = (OSClientSession.OSClientSessionV3) OSClientSession.OSClientSessionV3.getCurrent(); if (null != currentClient && currentToken.equals(currentClient.getToken())) { return currentClient; } return OSFactory.clientFromToken(currentToken, configOS4J); } SwiftKeystoneFactoryV3(StorageConfiguration configuration); OSClient.OSClientV3 get(); }
SwiftKeystoneFactoryV3 implements Supplier<OSClient> { public OSClient.OSClientV3 get() { Token currentToken = atomicToken.get(); Date nearTime = LocalDateUtil.getDate(LocalDateUtil.now().plusSeconds(configuration.getSwiftHardRenewTokenDelayBeforeExpireTime())); if (currentToken == null || currentToken.getExpires().before(nearTime)) { synchronized (monitor) { currentToken = atomicToken.get(); if (currentToken == null) { OSClient.OSClientV3 osClientV3 = renewToken(); currentToken = osClientV3.getToken(); atomicToken.set(currentToken); return osClientV3; } } } Date farTime = LocalDateUtil.getDate(LocalDateUtil.now().plusSeconds(configuration.getSwiftSoftRenewTokenDelayBeforeExpireTime())); if (currentToken.getExpires().before(farTime)) { if (oneThread.compareAndSet(true, false)) { try { OSClient.OSClientV3 osClientV3 = renewToken(); currentToken = osClientV3.getToken(); atomicToken.set(currentToken); return osClientV3; } finally { oneThread.set(true); } } } OSClientSession.OSClientSessionV3 currentClient = (OSClientSession.OSClientSessionV3) OSClientSession.OSClientSessionV3.getCurrent(); if (null != currentClient && currentToken.equals(currentClient.getToken())) { return currentClient; } return OSFactory.clientFromToken(currentToken, configOS4J); } SwiftKeystoneFactoryV3(StorageConfiguration configuration); OSClient.OSClientV3 get();  }