Package com.netflix.appinfo

Examples of com.netflix.appinfo.InstanceInfo$Builder


        }
        if (list.isEmpty() && includeRemoteRegions) {
            for (RemoteRegionRegistry remoteRegistry : this.regionNameVSRemoteRegistry.values()) {
                for (Application application : remoteRegistry.getApplications()
                                                             .getRegisteredApplications()) {
                    InstanceInfo instanceInfo = application.getByInstanceId(id);
                    if (instanceInfo != null) {
                        list.add(instanceInfo);
                        return list;
                    }
                }
View Full Code Here


     * @return true if enabled
     */
    public abstract boolean isLeaseExpirationEnabled();

    private InstanceInfo decorateInstanceInfo(Lease<InstanceInfo> lease) {
        InstanceInfo info = lease.getHolder();

        // client app settings
        int renewalInterval = LeaseInfo.DEFAULT_LEASE_RENEWAL_INTERVAL;
        int leaseDuration = LeaseInfo.DEFAULT_LEASE_DURATION;

        // TODO: clean this up
        if (info.getLeaseInfo() != null) {
            renewalInterval = info.getLeaseInfo().getRenewalIntervalInSecs();
            leaseDuration = info.getLeaseInfo().getDurationInSecs();
        }

        info.setLeaseInfo(LeaseInfo.Builder.newBuilder()
                                   .setRegistrationTimestamp(lease.getRegistrationTimestamp())
                                   .setRenewalTimestamp(lease.getLastRenewalTimestamp())
                                   .setServiceUpTimestamp(lease.getServiceUpTimestamp())
                                   .setRenewalIntervalInSecs(renewalInterval)
                                   .setDurationInSecs(leaseDuration)
                                   .setEvictionTimestamp(lease.getEvictionTimestamp()).build());

        info.setIsCoordinatingDiscoveryServer();
        return info;
    }
View Full Code Here

                    new V1AwareInstanceInfoConverter(),
                    XStream.PRIORITY_VERY_HIGH);
            XmlXStream.getInstance().registerConverter(
                    new V1AwareInstanceInfoConverter(),
                    XStream.PRIORITY_VERY_HIGH);
            InstanceInfo info = ApplicationInfoManager.getInstance().getInfo();

            PeerAwareInstanceRegistry registry = PeerAwareInstanceRegistry.getInstance();

            // Copy registry from neighboring eureka node
            int registryCount = registry.syncUp();
            registry.openForTraffic(registryCount);

            // Only in AWS, enable the binding functionality
            if (Name.Amazon.equals(info.getDataCenterInfo().getName())) {
                handleEIPBinding(registry);
            }
            // Initialize available remote registry
            PeerAwareInstanceRegistry.getInstance().initRemoteRegionRegistry();
            // Register all monitoring statistics.
View Full Code Here

     */
    public void contextDestroyed(ServletContextEvent event) {
        try {
            logger.info(new Date().toString()
                    + " Shutting down Eureka Server..");
            InstanceInfo info = ApplicationInfoManager.getInstance().getInfo();
            // Unregister all MBeans associated w/ DSCounters
            EurekaMonitors.shutdown();
            for (int i = 0; i < EurekaServerConfigurationManager.getInstance()
                    .getConfiguration().getEIPBindRebindRetries(); i++) {
                try {
                    if (Name.Amazon.equals(info.getDataCenterInfo().getName())) {
                        EIPManager.getInstance().unbindEIP();
                    }
                    break;
                } catch (Throwable e) {
                    logger.warn("Cannot unbind the EIP from the instance");
View Full Code Here

                logger.warn("DS: Registry: cancel failed because Lease is not registered for: "
                            + appName + ":" + id);
                return false;
            } else {
                leaseToCancel.cancel();
                InstanceInfo instanceInfo = leaseToCancel.getHolder();
                String vip = null;
                String svip = null;
                if (instanceInfo != null) {
                    instanceInfo.setActionType(ActionType.DELETED);
                    recentlyChangedQueue.add(new RecentlyChangedItem(
                            leaseToCancel));
                    instanceInfo.setLastUpdatedTimestamp();
                    vip = instanceInfo.getVIPAddress();
                    svip = instanceInfo.getSecureVipAddress();
                }
                invalidateCache(appName, vip, svip);
                logger.debug("DS: Registry: canceled lease: " + appName + " - "
                             + id);
                return true;
View Full Code Here

            RENEW_NOT_FOUND.increment(isReplication);
            logger.warn("DS: Registry: lease doesn't exist, registering resource: "
                        + appName + " - " + id);
            return false;
        } else {
            InstanceInfo instanceInfo = leaseToRenew.getHolder();
            if (instanceInfo != null) {
                // touchASGCache(instanceInfo.getASGName());
                InstanceStatus overriddenInstanceStatus = this
                        .getOverriddenInstanceStatus(instanceInfo,
                                leaseToRenew, isReplication);
                // InstanceStatus overriddenInstanceStatus =
                // instanceInfo.getStatus();
                if (!instanceInfo.getStatus().equals(overriddenInstanceStatus)) {
                    Object[] args = {instanceInfo.getStatus().name(),
                                     instanceInfo.getOverriddenStatus().name(),
                                     instanceInfo.getId()};
                    logger.info(
                            "The instance status {} is different from overridden instance status {} for instance {}. "
                            + "Hence setting the status to overridden status", args);
                    instanceInfo.setStatus(overriddenInstanceStatus);
                }
            }
            renewsLastMin.increment();
            leaseToRenew.renew();
            return true;
View Full Code Here

            }
            if (lease == null) {
                return false;
            } else {
                lease.renew();
                InstanceInfo info = lease.getHolder();
                if ((info != null) && !(info.getStatus().equals(newStatus))) {
                    // Mark service as UP if needed
                    if (InstanceStatus.UP.equals(newStatus)) {
                        lease.serviceUp();
                    }
                    // This is NAC overriden status
                    overriddenInstanceStatusMap.put(id, newStatus);
                    // Set it for transfer of overridden status to replica on
                    // replica start up
                    info.setOverriddenStatus(newStatus);
                    long replicaDirtyTimestamp = 0;
                    if (lastDirtyTimestamp != null) {
                        replicaDirtyTimestamp = Long
                                .valueOf(lastDirtyTimestamp);
                    }
                    // If the replication's dirty timestamp is more than the
                    // existing one, just update
                    // it to the replica's.
                    if (replicaDirtyTimestamp > info.getLastDirtyTimestamp()) {
                        info.setLastDirtyTimestamp(replicaDirtyTimestamp);
                        info.setStatusWithoutDirty(newStatus);
                    } else {
                        info.setStatus(newStatus);
                    }
                    info.setActionType(ActionType.MODIFIED);
                    recentlyChangedQueue
                            .add(new RecentlyChangedItem(lease));
                    info.setLastUpdatedTimestamp();
                    invalidateCache(appName, info.getVIPAddress(), info.getSecureVipAddress());
                }
                return true;
            }
        } finally {
            read.unlock();
View Full Code Here

            Iterator<RecentlyChangedItem> iter = this.recentlyChangedQueue.iterator();
            logger.debug("The number of elements in the delta queue is :"
                         + this.recentlyChangedQueue.size());
            while (iter.hasNext()) {
                Lease<InstanceInfo> lease = iter.next().getLeaseInfo();
                InstanceInfo instanceInfo = lease.getHolder();
                Object[] args = {instanceInfo.getId(),
                                 instanceInfo.getStatus().name(),
                                 instanceInfo.getActionType().name()};
                logger.debug(
                        "The instance id %s is found with status %s and actiontype %s",
                        args);
                Application app = applicationInstancesMap.get(instanceInfo
                        .getAppName());
                if (app == null) {
                    app = new Application(instanceInfo.getAppName());
                    applicationInstancesMap.put(instanceInfo.getAppName(), app);
                    apps.addApplication(app);
                }
                app.addInstance(decorateInstanceInfo(lease));
            }
View Full Code Here

            write.lock();
            Iterator<RecentlyChangedItem> iter = this.recentlyChangedQueue.iterator();
            logger.debug("The number of elements in the delta queue is :" + this.recentlyChangedQueue.size());
            while (iter.hasNext()) {
                Lease<InstanceInfo> lease = iter.next().getLeaseInfo();
                InstanceInfo instanceInfo = lease.getHolder();
                Object[] args = {instanceInfo.getId(),
                                 instanceInfo.getStatus().name(),
                                 instanceInfo.getActionType().name()};
                logger.debug(
                        "The instance id %s is found with status %s and actiontype %s",
                        args);
                Application app = applicationInstancesMap.get(instanceInfo
                        .getAppName());
                if (app == null) {
                    app = new Application(instanceInfo.getAppName());
                    applicationInstancesMap.put(instanceInfo.getAppName(), app);
                    apps.addApplication(app);
                }
                app.addInstance(decorateInstanceInfo(lease));
            }
View Full Code Here

         * com.thoughtworks.xstream.converters.MarshallingContext)
         */
        @Override
        public void marshal(Object source, HierarchicalStreamWriter writer,
                MarshallingContext context) {
            InstanceInfo info = (InstanceInfo) source;

            writer.startNode(ELEM_HOST);
            writer.setValue(info.getHostName());
            writer.endNode();

            writer.startNode(ELEM_APP);
            writer.setValue(info.getAppName());
            writer.endNode();

            writer.startNode(ELEM_IP);
            writer.setValue(info.getIPAddr());
            writer.endNode();

            if (!("unknown".equals(info.getSID()) || "na".equals(info.getSID()))) {
                writer.startNode(ELEM_SID);
                writer.setValue(info.getSID());
                writer.endNode();
            }

            writer.startNode(ELEM_STATUS);
            writer.setValue(getStatus(info));
            writer.endNode();

            writer.startNode(ELEM_OVERRIDDEN_STATUS);
            writer.setValue(info.getOverriddenStatus().name());
            writer.endNode();

            writer.startNode(ELEM_PORT);
            writer.addAttribute(ATTR_ENABLED,
                    String.valueOf(info.isPortEnabled(PortType.UNSECURE)));
            writer.setValue(String.valueOf(info.getPort()));
            writer.endNode();

            writer.startNode(ELEM_SECURE_PORT);
            writer.addAttribute(ATTR_ENABLED,
                    String.valueOf(info.isPortEnabled(PortType.SECURE)));
            writer.setValue(String.valueOf(info.getSecurePort()));
            writer.endNode();

            writer.startNode(ELEM_COUNTRY_ID);
            writer.setValue(String.valueOf(info.getCountryId()));
            writer.endNode();

            if (info.getDataCenterInfo() != null) {
                writer.startNode(NODE_DATACENTER);
                // This is needed for backward compat. for now.
                if (info.getDataCenterInfo().getName() == Name.Amazon) {
                    writer.addAttribute("class",
                    "com.netflix.appinfo.AmazonInfo");
                } else {
                    writer.addAttribute("class",
                    "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo");
                }
                context.convertAnother(info.getDataCenterInfo());
                writer.endNode();
            }

            if (info.getLeaseInfo() != null) {
                writer.startNode(NODE_LEASE);
                context.convertAnother(info.getLeaseInfo());
                writer.endNode();
            }

            if (info.getMetadata() != null) {
                writer.startNode(NODE_METADATA);
                // for backward compat. for now
                if (info.getMetadata().size() == 0) {
                    writer.addAttribute("class",
                    "java.util.Collections$EmptyMap");
                }
                context.convertAnother(info.getMetadata());
                writer.endNode();
            }
            autoMarshalEligible(source, writer);
        }
View Full Code Here

TOP

Related Classes of com.netflix.appinfo.InstanceInfo$Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.