Search in sources :

Example 86 with Action1

use of rx.functions.Action1 in project xDrip-plus by jamorham.

the class ReadDataShare method readSerialNumber.

public void readSerialNumber(final Action1<String> serialNumberListener) {
    final Action1<byte[]> manufacturingDataListener = new Action1<byte[]>() {

        @Override
        public void call(byte[] s) {
            Element el = ParsePage(s, Constants.RECORD_TYPES.MANUFACTURING_DATA.ordinal());
            Observable.just(el.getAttribute("SerialNumber")).subscribe(serialNumberListener);
        }
    };
    readDataBasePage(Constants.RECORD_TYPES.MANUFACTURING_DATA.ordinal(), 0, manufacturingDataListener);
}
Also used : Action1(rx.functions.Action1) Element(org.w3c.dom.Element)

Example 87 with Action1

use of rx.functions.Action1 in project xDrip-plus by jamorham.

the class ReadDataShare method readDataBasePage.

private <T> T readDataBasePage(final int recordType, int page, final Action1<byte[]> fullPageListener) {
    byte numOfPages = 1;
    if (page < 0) {
        throw new IllegalArgumentException("Invalid page requested:" + page);
    }
    ArrayList<Byte> payload = new ArrayList<Byte>();
    payload.add((byte) recordType);
    byte[] pageInt = ByteBuffer.allocate(4).putInt(page).array();
    payload.add(pageInt[3]);
    payload.add(pageInt[2]);
    payload.add(pageInt[1]);
    payload.add(pageInt[0]);
    payload.add(numOfPages);
    accumulatedResponse = null;
    final Action1<byte[]> databasePageReader = new Action1<byte[]>() {

        @Override
        public void call(byte[] s) {
            Log.d("ReadDataShare", "Database Page Reader received SIZE: " + s.length);
            byte[] temp = s;
            if (accumulatedResponse == null) {
                accumulatedResponse = s;
            } else {
                try {
                    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
                    outputStream.write(accumulatedResponse);
                    outputStream.write(temp);
                    accumulatedResponse = outputStream.toByteArray();
                    Log.d("ReadDataShare", "Combined Response length: " + accumulatedResponse.length);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
            if (temp.length < 20) {
                Observable.just(accumulatedResponse).subscribe(fullPageListener).unsubscribe();
            }
        }
    };
    writeCommand(Constants.READ_DATABASE_PAGES, payload, databasePageReader);
    return null;
}
Also used : Action1(rx.functions.Action1) ArrayList(java.util.ArrayList) ByteArrayOutputStream(java.io.ByteArrayOutputStream)

Example 88 with Action1

use of rx.functions.Action1 in project photon-model by vmware.

the class AzureComputeEnumerationAdapterService method processCreateUpdateNicRequest.

/**
 * Processes request for creating and updating Network interface resources.
 */
private void processCreateUpdateNicRequest(NetworkInterfaceState nic, NetworkInterfaceInner remoteNic, EnumerationContext ctx, List<DeferredResult<NetworkInterfaceState>> ops, Map<String, String> subnetPerNicId, boolean isCreate) {
    nic.name = remoteNic.name();
    nic.subnetLink = subnetPerNicId.get(remoteNic.id());
    NicMetadata nicMeta = new NicMetadata();
    nicMeta.state = nic;
    nicMeta.macAddress = remoteNic.macAddress();
    // else will default to original ID for PATCH requests
    if (isCreate) {
        nic.id = remoteNic.id();
        nic.endpointLink = ctx.request.endpointLink;
        AdapterUtils.addToEndpointLinks(nic, ctx.request.endpointLink);
        nic.tenantLinks = ctx.parentCompute.tenantLinks;
        nic.regionId = remoteNic.location();
        nic.computeHostLink = ctx.parentCompute.documentSelfLink;
    } else {
        if (StringUtils.isEmpty(nic.endpointLink)) {
            nic.endpointLink = ctx.request.endpointLink;
        }
        nic.endpointLinks.add(ctx.request.endpointLink);
    }
    List<NetworkInterfaceIPConfigurationInner> ipConfigurations = remoteNic.ipConfigurations();
    if (ipConfigurations == null || ipConfigurations.isEmpty()) {
        executeNicCreateUpdateRequest(nic, remoteNic, ctx, ops, nicMeta, isCreate);
        return;
    }
    NetworkInterfaceIPConfigurationInner nicIPConf = ipConfigurations.get(0);
    nic.address = nicIPConf.privateIPAddress();
    if (nicIPConf.publicIPAddress() == null) {
        executeNicCreateUpdateRequest(nic, remoteNic, ctx, ops, nicMeta, isCreate);
        return;
    }
    // IP address is not directly available in NetworkInterfaceIPConfigurationInner.
    // It is available as a SubResource, We use the SubResource ID of IP address from
    // NetworkInterfaceIPConfigurationInner to obtain the IP address.
    Consumer<Throwable> failure = e -> {
        logWarning("Error getting public IP address from Azure [endpointLink:%s], [Exception:%s]", ctx.request.endpointLink, e.getMessage());
        handleError(ctx, e);
    };
    PhotonModelUtils.runInExecutor(this.executorService, () -> {
        Azure azure = ctx.azureSdkClients.getAzureClient();
        azure.publicIPAddresses().getByIdAsync(nicIPConf.publicIPAddress().id()).subscribe(injectOperationContext(new Action1<PublicIPAddress>() {

            @Override
            public void call(PublicIPAddress publicIPAddress) {
                nicMeta.publicIp = publicIPAddress.ipAddress();
                if (publicIPAddress.inner().dnsSettings() != null) {
                    nicMeta.publicDnsName = publicIPAddress.inner().dnsSettings().fqdn();
                }
                executeNicCreateUpdateRequest(nic, remoteNic, ctx, ops, nicMeta, isCreate);
            }
        }));
    }, failure);
}
Also used : PowerState(com.vmware.photon.controller.model.resources.ComputeService.PowerState) Arrays(java.util.Arrays) ComputeEnumerateResourceRequest(com.vmware.photon.controller.model.adapterapi.ComputeEnumerateResourceRequest) ServiceTypeCluster(com.vmware.photon.controller.model.util.ClusterUtil.ServiceTypeCluster) LifecycleState(com.vmware.photon.controller.model.resources.ComputeService.LifecycleState) DISK_CONTROLLER_NUMBER(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.DISK_CONTROLLER_NUMBER) Action1(rx.functions.Action1) StringUtils(org.apache.commons.lang3.StringUtils) Azure(com.microsoft.azure.management.Azure) Utils(com.vmware.xenon.common.Utils) Pair(org.apache.commons.lang3.tuple.Pair) SubnetState(com.vmware.photon.controller.model.resources.SubnetService.SubnetState) Map(java.util.Map) StorageDescription(com.vmware.photon.controller.model.resources.StorageDescriptionService.StorageDescription) OSDisk(com.microsoft.azure.management.compute.OSDisk) ResourceEnumerationTaskService(com.vmware.photon.controller.model.tasks.ResourceEnumerationTaskService) NetworkInterfaceState(com.vmware.photon.controller.model.resources.NetworkInterfaceService.NetworkInterfaceState) StatelessService(com.vmware.xenon.common.StatelessService) Set(java.util.Set) NetworkInterfaceService(com.vmware.photon.controller.model.resources.NetworkInterfaceService) StorageAccountTypes(com.microsoft.azure.management.compute.StorageAccountTypes) TagService(com.vmware.photon.controller.model.resources.TagService) CompletionHandler(com.vmware.xenon.common.Operation.CompletionHandler) SOURCE_TASK_LINK(com.vmware.photon.controller.model.constants.PhotonModelConstants.SOURCE_TASK_LINK) InstanceViewStatus(com.microsoft.azure.management.compute.InstanceViewStatus) DeferredResult(com.vmware.xenon.common.DeferredResult) UriUtils(com.vmware.xenon.common.UriUtils) ComputeService(com.vmware.photon.controller.model.resources.ComputeService) NumericRange(com.vmware.xenon.services.common.QueryTask.NumericRange) AZURE_DATA_DISK_CACHING(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_DATA_DISK_CACHING) ImageReferenceInner(com.microsoft.azure.management.compute.implementation.ImageReferenceInner) VirtualMachinesInner(com.microsoft.azure.management.compute.implementation.VirtualMachinesInner) ComputeDescriptionService(com.vmware.photon.controller.model.resources.ComputeDescriptionService) PhotonModelUtils(com.vmware.photon.controller.model.resources.util.PhotonModelUtils) RegionInfo(com.vmware.photon.controller.model.adapterapi.RegionEnumerationResponse.RegionInfo) TagsUtil(com.vmware.photon.controller.model.adapters.util.TagsUtil) ArrayList(java.util.ArrayList) TagState(com.vmware.photon.controller.model.resources.TagService.TagState) ServiceStateCollectionUpdateRequest(com.vmware.xenon.common.ServiceStateCollectionUpdateRequest) Query(com.vmware.xenon.services.common.QueryTask.Query) EnumerationStages(com.vmware.photon.controller.model.adapters.util.enums.EnumerationStages) OperatingSystemTypes(com.microsoft.azure.management.compute.OperatingSystemTypes) BiConsumer(java.util.function.BiConsumer) AZURE_DIAGNOSTIC_STORAGE_ACCOUNT_LINK(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_DIAGNOSTIC_STORAGE_ACCOUNT_LINK) AZURE_STORAGE_ACCOUNT_URI(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_STORAGE_ACCOUNT_URI) VirtualMachineInner(com.microsoft.azure.management.compute.implementation.VirtualMachineInner) AdapterUtils(com.vmware.photon.controller.model.adapters.util.AdapterUtils) DataDisk(com.microsoft.azure.management.compute.DataDisk) ResourceState(com.vmware.photon.controller.model.resources.ResourceState) QueryUtils(com.vmware.photon.controller.model.query.QueryUtils) ENVIRONMENT_NAME_AZURE(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription.ENVIRONMENT_NAME_AZURE) QueryTop(com.vmware.photon.controller.model.query.QueryUtils.QueryTop) CUSTOM_OS_TYPE(com.vmware.photon.controller.model.ComputeProperties.CUSTOM_OS_TYPE) ComputeStateWithDescription(com.vmware.photon.controller.model.resources.ComputeService.ComputeStateWithDescription) PhotonModelConstants(com.vmware.photon.controller.model.constants.PhotonModelConstants) ComputeEnumerateAdapterRequest(com.vmware.photon.controller.model.adapters.util.ComputeEnumerateAdapterRequest) RegionEnumerationResponse(com.vmware.photon.controller.model.adapterapi.RegionEnumerationResponse) QuerySpecification(com.vmware.xenon.services.common.QueryTask.QuerySpecification) PhotonModelUriUtils.createInventoryUri(com.vmware.photon.controller.model.util.PhotonModelUriUtils.createInventoryUri) AuthCredentialsServiceState(com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState) QueryTask(com.vmware.xenon.services.common.QueryTask) AZURE_RESOURCE_GROUP_NAME(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_RESOURCE_GROUP_NAME) OSType(com.vmware.photon.controller.model.ComputeProperties.OSType) AzureUriPaths(com.vmware.photon.controller.model.adapters.azure.AzureUriPaths) AZURE_MANAGED_DISK_TYPE(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_MANAGED_DISK_TYPE) ComputeType(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription.ComputeType) AzureSdkClients(com.vmware.photon.controller.model.adapters.azure.utils.AzureSdkClients) AzureUtils.injectOperationContext(com.vmware.photon.controller.model.adapters.azure.utils.AzureUtils.injectOperationContext) CUSTOM_PROP_ENDPOINT_LINK(com.vmware.photon.controller.model.constants.PhotonModelConstants.CUSTOM_PROP_ENDPOINT_LINK) URI(java.net.URI) TagsUtil.newTagState(com.vmware.photon.controller.model.adapters.util.TagsUtil.newTagState) EndpointState(com.vmware.photon.controller.model.resources.EndpointService.EndpointState) AzureConstants(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants) AzureConstants.getQueryResultLimit(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.getQueryResultLimit) ComputeDescription(com.vmware.photon.controller.model.resources.ComputeDescriptionService.ComputeDescription) Collection(java.util.Collection) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) DiskState(com.vmware.photon.controller.model.resources.DiskService.DiskState) Occurance(com.vmware.xenon.services.common.QueryTask.Query.Occurance) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) List(java.util.List) AzureUtils(com.vmware.photon.controller.model.adapters.azure.utils.AzureUtils) AzureUtils.getResourceGroupName(com.vmware.photon.controller.model.adapters.azure.utils.AzureUtils.getResourceGroupName) TAG_KEY_TYPE(com.vmware.photon.controller.model.constants.PhotonModelConstants.TAG_KEY_TYPE) Entry(java.util.Map.Entry) NetworkInterfacesInner(com.microsoft.azure.management.network.implementation.NetworkInterfacesInner) QueryOption(com.vmware.xenon.services.common.QueryTask.QuerySpecification.QueryOption) InstanceViewTypes(com.microsoft.azure.management.compute.InstanceViewTypes) TagsUtil.setTagLinksToResourceState(com.vmware.photon.controller.model.adapters.util.TagsUtil.setTagLinksToResourceState) Builder(com.vmware.xenon.services.common.QueryTask.Query.Builder) DiskService(com.vmware.photon.controller.model.resources.DiskService) AzureUtils.isDiskManaged(com.vmware.photon.controller.model.adapters.azure.utils.AzureUtils.isDiskManaged) Default(com.vmware.photon.controller.model.adapters.azure.utils.AzureDeferredResultServiceCallback.Default) QueryByPages(com.vmware.photon.controller.model.query.QueryUtils.QueryByPages) AZURE_OSDISK_CACHING(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AZURE_OSDISK_CACHING) PublicIPAddress(com.microsoft.azure.management.network.PublicIPAddress) HashMap(java.util.HashMap) HashSet(java.util.HashSet) AuthCredentialsService(com.vmware.xenon.services.common.AuthCredentialsService) TagsUtil.updateLocalTagStates(com.vmware.photon.controller.model.adapters.util.TagsUtil.updateLocalTagStates) ComputeState(com.vmware.photon.controller.model.resources.ComputeService.ComputeState) EnumerationAction(com.vmware.photon.controller.model.adapterapi.EnumerationAction) AzureResourceType(com.vmware.photon.controller.model.adapters.azure.constants.AzureConstants.AzureResourceType) ExecutorService(java.util.concurrent.ExecutorService) Iterator(java.util.Iterator) NetworkInterfaceIPConfigurationInner(com.microsoft.azure.management.network.implementation.NetworkInterfaceIPConfigurationInner) Operation(com.vmware.xenon.common.Operation) Page(com.microsoft.azure.Page) TimeUnit(java.util.concurrent.TimeUnit) Consumer(java.util.function.Consumer) NetworkInterfaceReferenceInner(com.microsoft.azure.management.compute.implementation.NetworkInterfaceReferenceInner) AzureDeferredResultServiceCallback(com.vmware.photon.controller.model.adapters.azure.utils.AzureDeferredResultServiceCallback) NetworkInterfaceInner(com.microsoft.azure.management.network.implementation.NetworkInterfaceInner) Collections(java.util.Collections) OperationJoin(com.vmware.xenon.common.OperationJoin) RESOURCE_GROUP_NAME(com.vmware.photon.controller.model.ComputeProperties.RESOURCE_GROUP_NAME) Azure(com.microsoft.azure.management.Azure) NetworkInterfaceIPConfigurationInner(com.microsoft.azure.management.network.implementation.NetworkInterfaceIPConfigurationInner) Action1(rx.functions.Action1) PublicIPAddress(com.microsoft.azure.management.network.PublicIPAddress)

Example 89 with Action1

use of rx.functions.Action1 in project jocean-http by isdom.

the class MessageUtil method interact.

public static Interact interact(final HttpClient client) {
    final InitiatorBuilder _initiatorBuilder = client.initiator();
    final AtomicBoolean _isSSLEnabled = new AtomicBoolean(false);
    final AtomicReference<Observable<Object>> _obsreqRef = new AtomicReference<>(fullRequestWithoutBody(HttpVersion.HTTP_1_1, HttpMethod.GET));
    final List<String> _nvs = new ArrayList<>();
    final AtomicReference<URI> _uriRef = new AtomicReference<>();
    return new Interact() {

        private void updateObsRequest(final Action1<Object> action) {
            _obsreqRef.set(_obsreqRef.get().doOnNext(action));
        }

        private void addQueryParams() {
            if (!_nvs.isEmpty()) {
                updateObsRequest(MessageUtil.addQueryParam(_nvs.toArray(new String[0])));
            }
        }

        private void extractUriWithHost(final Object... reqbeans) {
            if (null == _uriRef.get()) {
                for (Object bean : reqbeans) {
                    try {
                        final Path path = bean.getClass().getAnnotation(Path.class);
                        if (null != path) {
                            final URI uri = new URI(path.value());
                            if (null != uri.getHost()) {
                                uri(path.value());
                                return;
                            }
                        }
                    } catch (Exception e) {
                        LOG.warn("exception when extract uri from bean {}, detail: {}", bean, ExceptionUtils.exception2detail(e));
                    }
                }
            }
        }

        private void checkAddr() {
            if (null == _uriRef.get()) {
                throw new RuntimeException("remote address not set.");
            }
        }

        private InitiatorBuilder addSSLFeatureIfNeed(final InitiatorBuilder builder) {
            if (_isSSLEnabled.get()) {
                return builder;
            } else if ("https".equals(_uriRef.get().getScheme())) {
                return builder.feature(F_SSL);
            } else {
                return builder;
            }
        }

        @Override
        public Interact method(final HttpMethod method) {
            updateObsRequest(MessageUtil.setMethod(method));
            return this;
        }

        @Override
        public Interact uri(final String uriAsString) {
            try {
                final URI uri = new URI(uriAsString);
                _uriRef.set(uri);
                _initiatorBuilder.remoteAddress(uri2addr(uri));
                updateObsRequest(MessageUtil.setHost(uri));
            } catch (URISyntaxException e) {
                throw new RuntimeException(e);
            }
            return this;
        }

        @Override
        public Interact path(final String path) {
            updateObsRequest(MessageUtil.setPath(path));
            return this;
        }

        @Override
        public Interact paramAsQuery(final String name, final String value) {
            _nvs.add(name);
            _nvs.add(value);
            return this;
        }

        @Override
        public Interact reqbean(final Object... reqbeans) {
            updateObsRequest(MessageUtil.toRequest(reqbeans));
            extractUriWithHost(reqbeans);
            return this;
        }

        @Override
        public Interact body(final Observable<? extends MessageBody> body) {
            _obsreqRef.set(_obsreqRef.get().compose(MessageUtil.addBody(body)));
            return this;
        }

        @Override
        public Interact body(final Object bean, final ContentEncoder contentEncoder) {
            return body(toBody(bean, contentEncoder.contentType(), contentEncoder.encoder()));
        }

        // @Override
        // public Interact disposeBodyOnTerminate(final boolean doDispose) {
        // _doDisposeBody.set(doDispose);
        // return this;
        // }
        @Override
        public Interact onrequest(final Action1<Object> action) {
            updateObsRequest(action);
            return this;
        }

        @Override
        public Interact feature(final Feature... features) {
            _initiatorBuilder.feature(features);
            if (isSSLEnabled(features)) {
                _isSSLEnabled.set(true);
            }
            return this;
        }

        private boolean isSSLEnabled(final Feature... features) {
            for (Feature f : features) {
                if (f instanceof Feature.ENABLE_SSL) {
                    return true;
                }
            }
            return false;
        }

        private Observable<? extends Object> hookDisposeBody(final Observable<Object> obsreq, final HttpInitiator initiator) {
            return obsreq.doOnNext(DisposableWrapperUtil.disposeOnForAny(initiator));
        }

        private Observable<? extends DisposableWrapper<HttpObject>> defineInteraction(final HttpInitiator initiator) {
            return initiator.defineInteraction(hookDisposeBody(_obsreqRef.get(), initiator));
        }

        @Override
        public Observable<? extends Interaction> execution() {
            checkAddr();
            addQueryParams();
            return addSSLFeatureIfNeed(_initiatorBuilder).build().map(new Func1<HttpInitiator, Interaction>() {

                @Override
                public Interaction call(final HttpInitiator initiator) {
                    final Observable<? extends DisposableWrapper<HttpObject>> interaction = defineInteraction(initiator);
                    return new Interaction() {

                        @Override
                        public HttpInitiator initiator() {
                            return initiator;
                        }

                        @Override
                        public Observable<? extends DisposableWrapper<HttpObject>> execute() {
                            return interaction;
                        }
                    };
                }
            });
        }
    };
}
Also used : DisposableWrapper(org.jocean.idiom.DisposableWrapper) ArrayList(java.util.ArrayList) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) HttpInitiator(org.jocean.http.client.HttpClient.HttpInitiator) HttpObject(io.netty.handler.codec.http.HttpObject) Path(javax.ws.rs.Path) Action1(rx.functions.Action1) AtomicReference(java.util.concurrent.atomic.AtomicReference) Observable(rx.Observable) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) HttpObject(io.netty.handler.codec.http.HttpObject) InitiatorBuilder(org.jocean.http.client.HttpClient.InitiatorBuilder) HttpMethod(io.netty.handler.codec.http.HttpMethod)

Example 90 with Action1

use of rx.functions.Action1 in project jocean-http by isdom.

the class MessageUtil method addQueryParam.

public static Action1<Object> addQueryParam(final String... nvs) {
    return new Action1<Object>() {

        @Override
        public void call(final Object obj) {
            if (obj instanceof HttpRequest) {
                final HttpRequest request = (HttpRequest) obj;
                if (nvs.length > 0) {
                    final QueryStringEncoder encoder = new QueryStringEncoder(request.uri());
                    int idx = 0;
                    while (idx + 1 < nvs.length) {
                        encoder.addParam(nvs[idx], nvs[idx + 1]);
                        idx += 2;
                    }
                    request.setUri(encoder.toString());
                }
            }
        }
    };
}
Also used : DefaultHttpRequest(io.netty.handler.codec.http.DefaultHttpRequest) HttpRequest(io.netty.handler.codec.http.HttpRequest) Action1(rx.functions.Action1) HttpObject(io.netty.handler.codec.http.HttpObject) QueryStringEncoder(io.netty.handler.codec.http.QueryStringEncoder)

Aggregations

Action1 (rx.functions.Action1)106 Test (org.junit.Test)33 Action0 (rx.functions.Action0)28 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)24 UiThreadTest (android.support.test.annotation.UiThreadTest)20 Observable (rx.Observable)18 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)12 HystrixRuntimeException (com.netflix.hystrix.exception.HystrixRuntimeException)11 ArrayList (java.util.ArrayList)11 CountDownLatch (java.util.concurrent.CountDownLatch)11 TestSubscriber (rx.observers.TestSubscriber)10 AllTypes (io.realm.entities.AllTypes)9 List (java.util.List)9 TestCircuitBreaker (com.netflix.hystrix.HystrixCircuitBreakerTest.TestCircuitBreaker)7 OnSubscribe (rx.Observable.OnSubscribe)7 RunTestInLooperThread (io.realm.rule.RunTestInLooperThread)6 IOException (java.io.IOException)6 PluginTestVerifier (com.navercorp.pinpoint.bootstrap.plugin.test.PluginTestVerifier)5 Method (java.lang.reflect.Method)5 AtomicReference (java.util.concurrent.atomic.AtomicReference)5