@Nullable private String queryMountPoint(@NonNull final String name) throws TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException, IOException { final AtomicReference<String> ref = Atomics.newReference(); executeShellCommand("echo $" + name, new MultiLineReceiver() { //$NON-NLS-1$ @Override public boolean isCancelled() { return false; } @Override public void processNewLines(String[] lines) { for (String line : lines) { if (!line.isEmpty()) { // this should be the only one. ref.set(line); } } } }); return ref.get(); }
@NotNull private static Result renderIntDefAnnotation(@NotNull final PsiAnnotation annotation, final int value) { final AtomicReference<AndroidResolveHelper.IntDefResolution> valuesRef = Atomics.newReference(); ApplicationManager.getApplication().runReadAction(new Runnable() { @Override public void run() { valuesRef.set(AndroidResolveHelper.resolveIntDef(annotation)); } }); AndroidResolveHelper.IntDefResolution intDef = valuesRef.get(); if (intDef.valuesMap == null) { renderUnknown("IntDef", value); } return new Result(String.format(Locale.US, "0x%1$08x {%2$s}", value, renderIntDef(value, intDef)), null); }
@Inject SuExec( final SshScope sshScope, @CommandName(Commands.ROOT) final DispatchCommandProvider dispatcher, PermissionBackend permissionBackend, final CurrentUser caller, final SshSession session, final IdentifiedUser.GenericFactory userFactory, final SshScope.Context callingContext, AuthConfig config) { this.sshScope = sshScope; this.dispatcher = dispatcher; this.permissionBackend = permissionBackend; this.caller = caller; this.session = session; this.userFactory = userFactory; this.callingContext = callingContext; this.enableRunAs = config.isRunAsEnabled(); atomicCmd = Atomics.newReference(); }
@Provides @Singleton protected Supplier<CacheLoader<RegionAndName, Image>> provideRegionAndNameToImageSupplierCacheLoader( final RegionAndIdToImage delegate) { return Suppliers.<CacheLoader<RegionAndName, Image>>ofInstance(new CacheLoader<RegionAndName, Image>() { private final AtomicReference<AuthorizationException> authException = Atomics.newReference(); @Override public Image load(final RegionAndName key) throws Exception { // raw lookup of an image Supplier<Image> rawSupplier = new Supplier<Image>() { @Override public Image get() { try { return delegate.load(key); } catch (ExecutionException e) { throw Throwables.propagate(e); } } }; return new SetAndThrowAuthorizationExceptionSupplier<Image>(rawSupplier, authException).get(); } }); }
@Inject RecoveryImpl( File backupDir, Function<Snapshot, TemporaryStorage> tempStorageFactory, Storage primaryStorage, DistributedSnapshotStore distributedStore, Command shutDownNow) { this.backupDir = requireNonNull(backupDir); this.tempStorageFactory = requireNonNull(tempStorageFactory); this.recovery = Atomics.newReference(); this.primaryStorage = requireNonNull(primaryStorage); this.distributedStore = requireNonNull(distributedStore); this.shutDownNow = requireNonNull(shutDownNow); }
@Nullable private static ConnectionState promptToRetryFailedConnection() { final AtomicReference<ConnectionState> atomicBoolean = Atomics.newReference(); Application application = ApplicationManager.getApplication(); application.invokeAndWait(new Runnable() { @Override public void run() { atomicBoolean.set(promptUserForProxy()); } }, application.getAnyModalityState()); return atomicBoolean.get(); }
@Inject protected OnStartStop( ServerInformation srvInfo, PushAll.Factory pushAll, ReplicationQueue queue, ReplicationConfig config, DynamicItem<EventDispatcher> eventDispatcher) { this.srvInfo = srvInfo; this.pushAll = pushAll; this.queue = queue; this.config = config; this.eventDispatcher = eventDispatcher; this.pushAllFuture = Atomics.newReference(); }
@Inject DispatchCommand( CurrentUser user, PermissionBackend permissionBackend, @Assisted Map<String, CommandProvider> all) { this.currentUser = user; this.permissionBackend = permissionBackend; commands = all; atomicCmd = Atomics.newReference(); }
AliasCommand( @CommandName(Commands.ROOT) DispatchCommandProvider root, PermissionBackend permissionBackend, CurrentUser currentUser, CommandName command) { this.root = root; this.permissionBackend = permissionBackend; this.currentUser = currentUser; this.command = command; this.atomicCmd = Atomics.newReference(); }
private Operation waitGCEOperationDone(Operation operation) { IaasProvider iaasInfo = getIaasProvider(); Injector injector = ContextBuilder.newBuilder(iaasInfo.getProvider()) .credentials(iaasInfo.getIdentity(), iaasInfo.getCredential()) .buildInjector(); Predicate<AtomicReference<Operation>> zoneOperationDonePredicate = injector.getInstance(Key.get(new TypeLiteral<Predicate<AtomicReference<Operation>>>() { }, Names.named("zone"))); AtomicReference<Operation> operationReference = Atomics.newReference(operation); retry(zoneOperationDonePredicate, MAX_WAIT_TIME, 1, SECONDS).apply(operationReference); return operationReference.get(); }
@Test public void testGetRequest() throws Exception { AtomicReference<Invocation> ref = Atomics.newReference(); proxy(ref).method(1, 2); RpcRequest request = protocol.getRequest(ref.get()); assertEquals(RpcRequest.GET, request.getMethod()); assertEquals("/method", request.getRelativePath()); assertEquals(ImmutableMap.of("arg0", "1", "arg1", "2"), request.getQuery()); assertTrue(request.getPost().isEmpty()); }
@Test public void testGetRequest_query() throws Exception { AtomicReference<Invocation> ref = Atomics.newReference(); proxy(ref).query(1, 2); RpcRequest request = protocol.getRequest(ref.get()); assertEquals("/query", request.getRelativePath()); assertEquals(ImmutableMap.of("arg0", "1", "arg1", "2"), request.getQuery()); assertTrue(request.getPost().isEmpty()); }
@Test public void testGetRequest_post() throws Exception { AtomicReference<Invocation> ref = Atomics.newReference(); proxy(ref).post(1, 2); RpcRequest request = protocol.getRequest(ref.get()); assertEquals(RpcRequest.POST, request.getMethod()); assertEquals("/post", request.getRelativePath()); assertTrue(request.getQuery().isEmpty()); assertEquals(ImmutableMap.of("arg0", "1", "arg1", "2"), request.getPost()); }
@Test public void testGetRequest_chainedMethods() throws Exception { AtomicReference<Invocation> ref = Atomics.newReference(); proxy(ref).interface0(1, 2).method(3, 4); RpcRequest request = protocol.getRequest(ref.get()); assertEquals(RpcRequest.GET, request.getMethod()); assertEquals("/interface0/1/2/method", request.getRelativePath()); assertEquals(ImmutableMap.of("arg0", "3", "arg1", "4"), request.getQuery()); assertTrue(request.getPost().isEmpty()); }
@Test public void testGetRequest_urlencodeArgs() throws Exception { AtomicReference<Invocation> ref = Atomics.newReference(); proxy(ref).interface0(1, 2).string0("привет"); RpcRequest request = protocol.getRequest(ref.get()); assertEquals("/interface0/1/2/string0", request.getRelativePath()); }
public BaseCommand() { task = Atomics.newReference(); }
Trampoline(String cmdLine) { commandLine = cmdLine; argv = split(cmdLine); logged = new AtomicBoolean(); task = Atomics.newReference(); }