Example usage for com.google.common.base Predicates instanceOf

List of usage examples for com.google.common.base Predicates instanceOf

Introduction

In this page you can find the example usage for com.google.common.base Predicates instanceOf.

Prototype

@GwtIncompatible("Class.isInstance")
public static Predicate<Object> instanceOf(Class<?> clazz) 

Source Link

Document

Returns a predicate that evaluates to true if the object being tested is an instance of the given class.

Usage

From source file:org.eclipse.sirius.diagram.ui.business.api.query.ConnectionQuery.java

/**
 * Return the constraint of the connection as list of RelativeBendpoint only
 * if the constraint is a list of relative bendpoints.
 * /*from w w  w  .  j  a  v a2  s  .c o m*/
 * @return an optional list of {@link RelativeBendpoint}
 */
public Option<List<RelativeBendpoint>> getRelativeBendpointsConstraint() {

    Object cons = connection.getRoutingConstraint();
    if (cons instanceof List) {
        List<?> constraintsList = (List<?>) cons;
        if (Iterators.all(constraintsList.iterator(), Predicates.instanceOf(RelativeBendpoint.class))) {
            List<RelativeBendpoint> result = Lists.newLinkedList();
            for (Object object : constraintsList) {
                result.add((RelativeBendpoint) object);
            }
            return Options.newSome(result);
        }
    }
    return Options.newNone();
}

From source file:org.eclipse.sirius.diagram.ui.graphical.edit.policies.SpecificBorderItemSelectionEditPolicy.java

/**
 * Return the list of existing feedback figures containing in the request.
 * If the request does not contains feedback figures, an empty list is
 * returned./* www . jav a2s .c  om*/
 * 
 * @param request
 *            The request containing the extended data.
 * @return the list of existing feedback figures contained in the request.
 */
@SuppressWarnings("unchecked")
private List<IFigure> getBorderNodeFeedbacks(Request request) {
    Object result = request.getExtendedData().get(BORDER_NODE_FEEDBACKS_KEY);
    if (result instanceof List<?> && Iterables.all((List<?>) result, Predicates.instanceOf(IFigure.class))) {
        return (List<IFigure>) result;
    } else {
        return new ArrayList<IFigure>();
    }
}

From source file:org.eclipse.sirius.diagram.business.api.query.DDiagramElementQuery.java

/**
 * Check if this {@link DDiagramElement} is indirectly collapsed.
 * //w ww  .j ava 2 s  .  co  m
 * @return true if the given element is indirectly filtered.
 */
public boolean isOnlyIndirectlyCollapsed() {
    return Iterables.any(element.getGraphicalFilters(), Predicates.instanceOf(IndirectlyCollapseFilter.class));
}

From source file:clocker.docker.entity.DockerInfrastructureImpl.java

@Override
public void init() {
    String version = config().get(DOCKER_VERSION);
    if (VersionComparator.getInstance().compare("1.9", version) > 1) {
        throw new IllegalStateException("Requires libnetwork capable Docker > 1.9");
    }/* w ww  . ja v  a2s  .com*/

    LOG.info("Starting Docker infrastructure id {}", getId());
    registerLocationResolver();
    super.init();

    int initialSize = config().get(DOCKER_HOST_CLUSTER_MIN_SIZE);

    Map<String, String> runtimeFiles = ImmutableMap.of();
    if (!config().get(DOCKER_GENERATE_TLS_CERTIFICATES)) {
        runtimeFiles = ImmutableMap.<String, String>builder()
                .put(config().get(DOCKER_SERVER_CERTIFICATE_PATH), "cert.pem")
                .put(config().get(DOCKER_SERVER_KEY_PATH), "key.pem")
                .put(config().get(DOCKER_CA_CERTIFICATE_PATH), "ca.pem").build();
    }

    // Try and set the registry URL if configured and not starting local registry
    if (!config().get(DOCKER_SHOULD_START_REGISTRY)) {
        ConfigToAttributes.apply(this, DOCKER_IMAGE_REGISTRY_URL);
    }

    try {
        String caCertPath = config().get(DOCKER_CA_CERTIFICATE_PATH);
        try (InputStream caCert = ResourceUtils.create().getResourceFromUrl(caCertPath)) {
            X509Certificate certificate = (X509Certificate) CertificateFactory.getInstance("X.509")
                    .generateCertificate(caCert);
            KeyStore store = SecureKeys.newKeyStore();
            store.setCertificateEntry("ca", certificate);
            X509TrustManager trustManager = SecureKeys.getTrustManager(certificate);
            // TODO incorporate this trust manager into jclouds SSL context
        }
    } catch (IOException | KeyStoreException | CertificateException e) {
        Exceptions.propagate(e);
    }

    EntitySpec<?> dockerHostSpec = EntitySpec.create(config().get(DOCKER_HOST_SPEC));
    dockerHostSpec.configure(DockerHost.DOCKER_INFRASTRUCTURE, this)
            .configure(DockerHost.RUNTIME_FILES, runtimeFiles)
            .configure(SoftwareProcess.CHILDREN_STARTABLE_MODE, ChildStartableMode.BACKGROUND_LATE);
    String dockerVersion = config().get(DOCKER_VERSION);
    if (Strings.isNonBlank(dockerVersion)) {
        dockerHostSpec.configure(SoftwareProcess.SUGGESTED_VERSION, dockerVersion);
    }
    if (Boolean.TRUE.equals(config().get(SdnAttributes.SDN_DEBUG))) {
        dockerHostSpec.configure(DockerAttributes.DOCKERFILE_URL, DockerUtils.UBUNTU_NETWORKING_DOCKERFILE);
    }
    sensors().set(DOCKER_HOST_SPEC, dockerHostSpec);

    DynamicCluster hosts = addChild(
            EntitySpec.create(DynamicCluster.class).configure(Cluster.INITIAL_SIZE, initialSize)
                    .configure(DynamicCluster.QUARANTINE_FAILED_ENTITIES, true)
                    .configure(DynamicCluster.MEMBER_SPEC, dockerHostSpec)
                    .configure(DynamicCluster.RUNNING_QUORUM_CHECK, QuorumChecks.atLeastOneUnlessEmpty())
                    .configure(DynamicCluster.UP_QUORUM_CHECK, QuorumChecks.atLeastOneUnlessEmpty())
                    .configure(BrooklynCampConstants.PLAN_ID, "docker-hosts").displayName("Docker Hosts"));

    EntitySpec<?> etcdNodeSpec = EntitySpec.create(config().get(EtcdCluster.ETCD_NODE_SPEC));
    String etcdVersion = config().get(ETCD_VERSION);
    if (Strings.isNonBlank(etcdVersion)) {
        etcdNodeSpec.configure(SoftwareProcess.SUGGESTED_VERSION, etcdVersion);
    }
    sensors().set(EtcdCluster.ETCD_NODE_SPEC, etcdNodeSpec);

    EtcdCluster etcd = addChild(EntitySpec.create(EtcdCluster.class).configure(Cluster.INITIAL_SIZE, 0)
            .configure(EtcdCluster.ETCD_NODE_SPEC, etcdNodeSpec).configure(EtcdCluster.CLUSTER_NAME, "docker")
            .configure(EtcdCluster.CLUSTER_TOKEN, "etcd-docker")
            .configure(DynamicCluster.QUARANTINE_FAILED_ENTITIES, true)
            .configure(DynamicCluster.RUNNING_QUORUM_CHECK, QuorumChecks.atLeastOneUnlessEmpty())
            .configure(DynamicCluster.UP_QUORUM_CHECK, QuorumChecks.atLeastOneUnlessEmpty())
            .displayName("Etcd Cluster"));
    sensors().set(ETCD_CLUSTER, etcd);

    DynamicGroup fabric = addChild(EntitySpec.create(DynamicGroup.class)
            .configure(DynamicGroup.ENTITY_FILTER,
                    Predicates.and(Predicates.instanceOf(DockerContainer.class),
                            EntityPredicates.attributeEqualTo(DockerContainer.DOCKER_INFRASTRUCTURE, this)))
            .displayName("All Docker Containers"));

    if (config().get(SDN_ENABLE) && config().get(SDN_PROVIDER_SPEC) != null) {
        EntitySpec entitySpec = EntitySpec.create(config().get(SDN_PROVIDER_SPEC));
        entitySpec.configure(DockerAttributes.DOCKER_INFRASTRUCTURE, this);
        Entity sdn = addChild(entitySpec);
        sensors().set(SDN_PROVIDER, sdn);
    }

    sensors().set(DOCKER_HOST_CLUSTER, hosts);
    sensors().set(DOCKER_CONTAINER_FABRIC, fabric);

    hosts.enrichers().add(Enrichers.builder().aggregating(DockerHost.CPU_USAGE).computingAverage().fromMembers()
            .publishing(MachineAttributes.AVERAGE_CPU_USAGE).valueToReportIfNoSensors(0d).build());
    hosts.enrichers().add(Enrichers.builder().aggregating(DOCKER_CONTAINER_COUNT).computingSum().fromMembers()
            .publishing(DOCKER_CONTAINER_COUNT).build());

    enrichers().add(Enrichers.builder().propagating(DOCKER_CONTAINER_COUNT, MachineAttributes.AVERAGE_CPU_USAGE)
            .from(hosts).build());
    enrichers().add(Enrichers.builder()
            .propagating(ImmutableMap.of(DynamicCluster.GROUP_SIZE, DOCKER_HOST_COUNT)).from(hosts).build());

    Integer headroom = config().get(ContainerHeadroomEnricher.CONTAINER_HEADROOM);
    Double headroomPercent = config().get(ContainerHeadroomEnricher.CONTAINER_HEADROOM_PERCENTAGE);
    if ((headroom != null && headroom > 0) || (headroomPercent != null && headroomPercent > 0d)) {
        enrichers().add(EnricherSpec.create(ContainerHeadroomEnricher.class)
                .configure(ContainerHeadroomEnricher.CONTAINER_HEADROOM, headroom)
                .configure(ContainerHeadroomEnricher.CONTAINER_HEADROOM_PERCENTAGE, headroomPercent));
        hosts.enrichers()
                .add(Enrichers.builder()
                        .propagating(ContainerHeadroomEnricher.DOCKER_CONTAINER_CLUSTER_COLD,
                                ContainerHeadroomEnricher.DOCKER_CONTAINER_CLUSTER_HOT,
                                ContainerHeadroomEnricher.DOCKER_CONTAINER_CLUSTER_OK)
                        .from(this).build());
        hosts.policies()
                .add(PolicySpec.create(AutoScalerPolicy.class)
                        .configure(AutoScalerPolicy.POOL_COLD_SENSOR,
                                ContainerHeadroomEnricher.DOCKER_CONTAINER_CLUSTER_COLD)
                        .configure(AutoScalerPolicy.POOL_HOT_SENSOR,
                                ContainerHeadroomEnricher.DOCKER_CONTAINER_CLUSTER_HOT)
                        .configure(AutoScalerPolicy.POOL_OK_SENSOR,
                                ContainerHeadroomEnricher.DOCKER_CONTAINER_CLUSTER_OK)
                        .configure(AutoScalerPolicy.MIN_POOL_SIZE, initialSize)
                        .configure(AutoScalerPolicy.RESIZE_UP_STABILIZATION_DELAY, Duration.THIRTY_SECONDS)
                        .configure(AutoScalerPolicy.RESIZE_DOWN_STABILIZATION_DELAY, Duration.FIVE_MINUTES)
                        .displayName("Headroom Auto Scaler"));
    }

    sensors().set(Attributes.MAIN_URI, URI.create("/clocker"));

    // Override the health-check: just interested in the docker infrastructure/SDN, rather than 
    // the groups that show the apps.
    Entity sdn = sensors().get(SDN_PROVIDER);
    enrichers()
            .add(EnricherSpec.create(ComputeServiceIndicatorsFromChildrenAndMembers.class)
                    .uniqueTag(ComputeServiceIndicatorsFromChildrenAndMembers.DEFAULT_UNIQUE_TAG)
                    .configure(ComputeServiceIndicatorsFromChildrenAndMembers.FROM_CHILDREN, true)
                    .configure(ComputeServiceIndicatorsFromChildrenAndMembers.ENTITY_FILTER, Predicates.or(
                            Predicates.<Entity>equalTo(hosts),
                            (sdn == null ? Predicates.<Entity>alwaysFalse() : Predicates.equalTo(sdn)))));
}

From source file:org.dasein.cloud.jclouds.vcloud.director.compute.VAppTemplateSupport.java

private @Nonnull MachineImage executeImage(@Nonnull String vmId, @Nonnull String name,
        @Nonnull String description) throws CloudException, InternalException {
    RestContext<VCloudDirectorAdminClient, VCloudDirectorAdminAsyncClient> ctx = provider.getCloudClient();

    try {/*from  w  w w. j a va2  s.  com*/
        try {
            VirtualMachine vm = provider.getComputeServices().getVirtualMachineSupport()
                    .getVirtualMachine(vmId);
            Vm vcloudVm = ctx.getApi().getVmClient().getVm(provider.toHref(ctx, vmId));
            VApp parent = ctx.getApi().getVAppClient().getVApp(vcloudVm.getVAppParent().getHref());

            if (parent.getStatus().equals(Status.POWERED_ON)) {
                provider.waitForTask(ctx.getApi().getVAppClient().powerOff(parent.getHref()));
            }
            UndeployVAppParams params = UndeployVAppParams.builder().undeployPowerAction(PowerAction.POWER_OFF)
                    .build();
            provider.waitForTask(ctx.getApi().getVAppClient().undeploy(parent.getHref(), params));
            HashMap<String, Collection<NetworkConnection.Builder>> oldBuilders = new HashMap<String, Collection<NetworkConnection.Builder>>();
            for (Vm child : parent.getChildren().getVms()) {
                ArrayList<NetworkConnection.Builder> list = new ArrayList<NetworkConnection.Builder>();
                NetworkConnectionSection section = (NetworkConnectionSection) Iterables
                        .find(child.getSections(), Predicates.instanceOf(NetworkConnectionSection.class));
                for (NetworkConnection c : section.getNetworkConnections()) {
                    NetworkConnection.Builder builder = NetworkConnection.builder().fromNetworkConnection(c);
                    list.add(builder);
                }
                oldBuilders.put(provider.toId(ctx, child.getHref()), list);
            }
            /*
             * IPAddress allocation mode nonsense
            for( Vm child : parent.getChildren() ) {
            Builder sectionBuilder = child.getNetworkConnectionSection().toBuilder();
            ArrayList<NetworkConnection> connections = new ArrayList<NetworkConnection>();
                    
            for( NetworkConnection c : child.getNetworkConnectionSection().getConnections() ) {
                NetworkConnection.Builder builder = NetworkConnection.Builder.fromNetworkConnection(c);
                    
                builder.connected(false);
                builder.ipAddressAllocationMode(IpAddressAllocationMode.NONE);
                connections.add(builder.build());
            }
            sectionBuilder.connections(connections);
            provider.waitForTask(ctx.getApi().getVmClient().updateNetworkConnectionOfVm(sectionBuilder.build(), child.getHref()));
            }
            */
            /*
            System.out.println("Powering it back on...");
            provider.waitForTask(ctx.getApi().getVAppClient().deployAndPowerOnVApp(parent.getHref()));
            parent = provider.waitForIdle(ctx, parent);
            System.out.println("Turning it back off...");
            provider.waitForTask(ctx.getApi().getVAppClient().undeployAndSaveStateOfVApp(parent.getHref())); 
            */
            parent = provider.waitForIdle(ctx, parent);
            if (logger.isInfoEnabled()) {
                logger.info("Building template from " + vm);
            }
            VAppTemplate template;
            try {
                CaptureVAppParams capture = CaptureVAppParams.builder().description(description).build();

                template = ctx.getApi().getVdcClient().captureVApp(parent.getHref(), capture);

                if (logger.isDebugEnabled()) {
                    logger.debug("Template=" + template);
                }
                Catalog catalog = findCatalog(ctx);

                if (logger.isInfoEnabled()) {
                    logger.info("Adding " + template + " to catalog " + catalog);
                }
                if (catalog != null) {
                    // note you can also add properties here, if you want
                    Reference ref = Reference.builder().fromEntity(template).build();
                    CatalogItem item = CatalogItem.builder().name(name).description(description).entity(ref)
                            .build();
                    ctx.getApi().getCatalogClient().addCatalogItem(catalog.getHref(), item);
                    if (logger.isInfoEnabled()) {
                        logger.info("Template added to catalog");
                    }
                } else {
                    logger.warn("No catalog exists for this template");
                }
            } finally {
                if (logger.isInfoEnabled()) {
                    logger.info("Turning source VM back on");
                }
                try {
                    parent = provider.waitForIdle(ctx, parent);
                    for (Vm child : parent.getChildren().getVms()) {
                        child = provider.waitForIdle(ctx, child);

                        String id = provider.toId(ctx, child.getHref());
                        Collection<NetworkConnection.Builder> builders = oldBuilders.get(id);
                        Set<NetworkConnection> connections = Sets.newLinkedHashSet();

                        for (NetworkConnection.Builder builder : builders) {
                            builder.isConnected(true);
                            connections.add(builder.build());
                        }
                        NetworkConnectionSection section = VmSupport
                                .getSection(child, NetworkConnectionSection.class).toBuilder()
                                .networkConnections(connections).build();
                        if (logger.isInfoEnabled()) {
                            logger.info("Resetting network connection for " + child);
                        }
                        provider.waitForTask(ctx.getApi().getVmClient()
                                .modifyNetworkConnectionSection(child.getHref(), section));
                    }
                    parent = provider.waitForIdle(ctx, parent);
                    try {
                        logger.info("Powering VM " + parent + " on");
                        DeployVAppParams deploy = DeployVAppParams.builder().powerOn().build();
                        provider.waitForTask(ctx.getApi().getVAppClient().deploy(parent.getHref(), deploy));
                    } catch (Throwable t) {
                        logger.warn("Failed to power on VM " + parent);
                    }
                } catch (Throwable t) {
                    logger.warn("Error upading network connection for source VM: " + t.getMessage());
                    if (logger.isDebugEnabled()) {
                        t.printStackTrace();
                    }
                }
            }
            if (logger.isInfoEnabled()) {
                logger.info("Populating dasein image for new template: " + template);
            }
            return toMachineImage(ctx, provider.getOrg(vm.getProviderOwnerId()),
                    ctx.getApi().getVAppTemplateClient().getVAppTemplate(template.getHref()));
        } catch (RuntimeException e) {
            logger.error("Error creating template from " + vmId + ": " + e.getMessage());
            if (logger.isDebugEnabled()) {
                e.printStackTrace();
            }
            throw new CloudException(e);
        }
    } finally {
        ctx.close();
    }
}

From source file:org.eclipse.sirius.diagram.business.api.query.DDiagramElementQuery.java

/**
 * Check if this {@link DDiagramElement} is directly filtered by an
 * activated filter.//w  w w.  j a  v a  2  s.  c om
 * 
 * @return true if the given element is filtered.
 */
public boolean isFiltered() {
    return Iterables.any(element.getGraphicalFilters(), Predicates.instanceOf(AppliedCompositeFilters.class));
}

From source file:org.eclipse.sirius.diagram.ui.tools.internal.actions.straighten.StraightenToAction.java

/**
 * Return only a list of selected AbstractDiagramEdgeEditPart that
 * understands the request. If there is at least one other kind of edit
 * part, an empty list is returned./*from  www  . ja va  2  s.c om*/
 * 
 * @return A list of {@link AbstractDiagramEdgeEditPart} selected.
 */
@Override
protected List<?> createOperationSet() {
    List<?> selection = getSelectedObjects();
    if (!Iterables.all(selection, Predicates.instanceOf(AbstractDiagramEdgeEditPart.class))) {
        selection = Collections.EMPTY_LIST;
    }
    return selection;
}

From source file:vazkii.botania.common.block.tile.mana.TileSpreader.java

@Override
public void update() {
    boolean inNetwork = ManaNetworkHandler.instance.isCollectorIn(this);
    boolean wasInNetwork = inNetwork;
    if (!inNetwork && !isInvalid()) {
        ManaNetworkEvent.addCollector(this);
    }/* w  w w .j a  v a 2  s  . co  m*/

    boolean redstone = false;

    for (EnumFacing dir : EnumFacing.VALUES) {
        TileEntity tileAt = worldObj.getTileEntity(pos.offset(dir));
        if (worldObj.isBlockLoaded(pos.offset(dir), false) && tileAt instanceof IManaPool) {
            IManaPool pool = (IManaPool) tileAt;
            if (wasInNetwork && (pool != receiver || isRedstone())) {
                if (pool instanceof IKeyLocked && !((IKeyLocked) pool).getOutputKey().equals(getInputKey()))
                    continue;

                int manaInPool = pool.getCurrentMana();
                if (manaInPool > 0 && !isFull()) {
                    int manaMissing = getMaxMana() - mana;
                    int manaToRemove = Math.min(manaInPool, manaMissing);
                    pool.recieveMana(-manaToRemove);
                    recieveMana(manaToRemove);
                }
            }
        }

        int redstoneSide = worldObj.getRedstonePower(pos.offset(dir), dir);
        if (redstoneSide > 0)
            redstone = true;
    }

    if (needsNewBurstSimulation())
        checkForReceiver();

    if (!canShootBurst)
        if (pingbackTicks <= 0) {
            double x = lastPingbackX;
            double y = lastPingbackY;
            double z = lastPingbackZ;
            AxisAlignedBB aabb = new AxisAlignedBB(x, y, z, x, y, z).expand(PINGBACK_EXPIRED_SEARCH_DISTANCE,
                    PINGBACK_EXPIRED_SEARCH_DISTANCE, PINGBACK_EXPIRED_SEARCH_DISTANCE);
            List bursts = worldObj.getEntitiesWithinAABB(Entity.class, aabb,
                    Predicates.instanceOf(IManaBurst.class));
            IManaBurst found = null;
            UUID identity = getIdentifier();
            for (IManaBurst burst : (List<IManaBurst>) bursts)
                if (burst != null && identity.equals(burst.getShooterUUID())) {
                    found = burst;
                    break;
                }

            if (found != null)
                found.ping();
            else
                setCanShoot(true);
        } else
            pingbackTicks--;

    boolean shouldShoot = !redstone;

    boolean isredstone = isRedstone();
    if (isredstone)
        shouldShoot = redstone && !redstoneLastTick;

    if (shouldShoot && receiver != null && receiver instanceof IKeyLocked)
        shouldShoot = ((IKeyLocked) receiver).getInputKey().equals(getOutputKey());

    ItemStack lens = itemHandler.getStackInSlot(0);
    ILensControl control = getLensController(lens);
    if (control != null) {
        if (isredstone) {
            if (shouldShoot)
                control.onControlledSpreaderPulse(lens, this, redstone);
        } else
            control.onControlledSpreaderTick(lens, this, redstone);

        shouldShoot &= control.allowBurstShooting(lens, this, redstone);
    }

    if (shouldShoot)
        tryShootBurst();

    if (receiverLastTick != receiver && !worldObj.isRemote) {
        requestsClientUpdate = true;
        VanillaPacketDispatcher.dispatchTEToNearbyPlayers(worldObj, pos);
    }

    redstoneLastTick = redstone;
    receiverLastTick = receiver;
}

From source file:org.sosy_lab.cpachecker.cpa.bam.ARGSubtreeRemover.java

private void removeCachedSubtree(ARGState rootState, ARGState removeElement, List<Precision> pNewPrecisions,
        List<Predicate<? super Precision>> pPrecisionTypes) {
    removeCachedSubtreeTimer.start();/*from   w w  w. ja v  a 2s  . c o  m*/

    try {
        CFANode rootNode = extractLocation(rootState);
        Block rootSubtree = partitioning.getBlockForCallNode(rootNode);

        logger.log(Level.FINER, "Remove cached subtree for", removeElement, "(rootNode: ", rootNode,
                ") issued with precision", pNewPrecisions);

        AbstractState reducedRootState = wrappedReducer.getVariableReducedState(rootState, rootSubtree,
                rootNode);
        ReachedSet reachedSet = abstractStateToReachedSet.get(rootState);

        if (removeElement.isDestroyed()) {
            logger.log(Level.FINER, "state was destroyed before");
            //apparently, removeElement was removed due to prior deletions
            return;
        }

        assert reachedSet.contains(removeElement) : "removing state from wrong reachedSet: " + removeElement;

        Precision removePrecision = reachedSet.getPrecision(removeElement);
        ArrayList<Precision> newReducedRemovePrecision = null; // TODO newReducedRemovePrecision: NullPointerException 20 lines later!

        if (pNewPrecisions != null) {
            newReducedRemovePrecision = new ArrayList<>(1);

            for (int i = 0; i < pNewPrecisions.size(); i++) {
                removePrecision = Precisions.replaceByType(removePrecision, pNewPrecisions.get(i),
                        pPrecisionTypes.get(i));
            }

            newReducedRemovePrecision
                    .add(wrappedReducer.getVariableReducedPrecision(removePrecision, rootSubtree));
            pPrecisionTypes = new ArrayList<>();
            pPrecisionTypes.add(Predicates.instanceOf(newReducedRemovePrecision.get(0).getClass()));
        }

        assert !removeElement.getParents().isEmpty();

        Precision reducedRootPrecision = reachedSet.getPrecision(reachedSet.getFirstState());
        bamCache.removeReturnEntry(reducedRootState, reducedRootPrecision, rootSubtree);
        bamCache.removeBlockEntry(reducedRootState, reducedRootPrecision, rootSubtree);

        logger.log(Level.FINEST,
                "Removing subtree, adding a new cached entry, and removing the former cached entries");

        if (removeSubtree(reachedSet, removeElement, newReducedRemovePrecision, pPrecisionTypes)) {
            logger.log(Level.FINER, "updating cache");
            bamCache.updatePrecisionForEntry(reducedRootState, reducedRootPrecision, rootSubtree,
                    newReducedRemovePrecision.get(0));
        }

    } finally {
        removeCachedSubtreeTimer.stop();
    }
}

From source file:com.eucalyptus.cluster.callback.VmRunCallback.java

private Address getAddress() {
    final PublicIPResource publicIPResource = (PublicIPResource) Iterables.find(
            VmRunCallback.this.token.getAttribute(NetworkResourceVmInstanceLifecycleHelper.NetworkResourcesKey),
            Predicates.instanceOf(PublicIPResource.class), null);
    return publicIPResource != null && publicIPResource.getValue() != null
            ? Addresses.getInstance().lookup(publicIPResource.getValue())
            : null;//from  w  w  w .  jav  a2  s  .  c o m
}