Package com.webobjects.foundation

Examples of com.webobjects.foundation.NSTimestamp


        theApplication._lock.startReading();
        try {
            MInstance instance = ((Application) WOApplication.application()).siteConfig().instanceWithHostAndPort(instanceName, hostAddress, port);

            if (instance != null) {
                instance.startRegistration(new NSTimestamp());
                instance.setShouldDie(false);
            } else {
                ((Application) WOApplication.application()).localMonitor().registerUnknownInstance(instanceName, host, port);
            }
        } finally {
View Full Code Here


        theApplication._lock.startReading();
        try {
            MInstance instance = ((Application) WOApplication.application()).siteConfig().instanceWithHostAndPort(instanceName, hostAddress, port);

            if (instance != null) {
                instance.updateRegistration(new NSTimestamp());
                // This call will reset shouldDie status!;
                return !instance.shouldDieAndReset();
            }
            ((Application) WOApplication.application()).localMonitor().registerUnknownInstance(instanceName, host, port);
        } finally {
View Full Code Here

        theApplication._lock.startReading();
        try {
            MInstance instance = ((Application) WOApplication.application()).siteConfig().instanceWithHostAndPort(instanceName, hostAddress, port);
            if (instance != null) {
                instance.registerStop(new NSTimestamp());
                instance.setShouldDie(false);
                instance.cancelForceQuitTask();
            }
        } finally {
            theApplication._lock.endReading();
View Full Code Here

        theApplication._lock.startReading();
        try {
            MInstance instance = ((Application) WOApplication.application()).siteConfig().instanceWithHostAndPort(instanceName, hostAddress, port);

            if (instance != null) {
                instance.registerCrash(new NSTimestamp());
                instance.setShouldDie(false);
                instance.cancelForceQuitTask();
            }
        } finally {
            theApplication._lock.endReading();
View Full Code Here

     */
    protected Object newWithDelta(Object val, double delta) {
        double v;

        if (val instanceof NSTimestamp) {
            NSTimestamp vts = (NSTimestamp)val;
            NSTimestamp nvts = vts.timestampByAddingGregorianUnits(0, 0, 0, 0, 0, (int)delta);
            return nvts;
        } else if (val instanceof Number) {
            v = DRValueConverter.converter().doubleForValue(val) + delta;
            return (Double.valueOf(v));
        }
View Full Code Here

     */
    public String lookUpKeyForValue(Object aVal) {
        String s;

        if (_useTimeFormat) {
            NSTimestamp ts = DRValueConverter.converter().timestampForValue(aVal);
            Format formatter = DRCriteria.formatterForFormat(_format);
            try {
                s = formatter.format(ts);
            } catch(Exception ex) {
                log.warn("Error lookup " + ex + ", value=" + aVal + ": " + this);
View Full Code Here

            }
        } else if(v instanceof Number){
            Number vv = (Number)v;
            scr = vv.doubleValue();
        } else if (v instanceof NSTimestamp) {
            NSTimestamp vv = (NSTimestamp)v;
            scr = vv.getTime() / 1000.0;
        } else if(v == NSKeyValueCoding.NullValue) {
            scr = 0.0;
        } else {
            try {
                scr = Double.parseDouble(v.toString());
View Full Code Here

        _hostName = theApplication.host();
    }

    private NSTimestamp calculateNearestHour() {
        NSTimestamp currentTime = new NSTimestamp();

        TimeZone currentTimeZone = currentTime.timeZone();
        int currentYear = currentTime.yearOfCommonEra();
        int currentMonth = currentTime.monthOfYear();
        int currentDayOfMonth = currentTime.dayOfMonth()// [1,31]
        int currentHourOfDay = currentTime.hourOfDay();    // [0,23]

        return new NSTimestamp(currentYear, currentMonth, currentDayOfMonth, currentHourOfDay+1, 0, 0, currentTimeZone);
    }
View Full Code Here

    public void registerUnknownInstance(String name, String host, String port) {
        _unknownAppLock.startWriting();


        try {
            NSTimestamp currentTime = new NSTimestamp();
            // Don't regenerate the localhost list for random applications
            if ( WOHostUtilities.isLocalInetAddress(InetAddress.getByName(host), false) ) {
                NSMutableDictionary appDict = (NSMutableDictionary) _unknownApplications.valueForKey(name);
                if (appDict != null) {
                    appDict.takeValueForKey(currentTime, port);
View Full Code Here

        _unknownAppLock.startWriting();

        try {
            NSMutableDictionary unknownApps = _unknownApplications;
            // Should make this configurable?
            NSTimestamp cutOffDate = new NSTimestamp(System.currentTimeMillis() - 45000);

            NSArray unknownAppKeys = unknownApps.allKeys();
            for (Enumeration e = unknownAppKeys.objectEnumerator(); e.hasMoreElements(); ) {
                String unknownAppKey = (String) e.nextElement();
                NSMutableDictionary appDict = (NSMutableDictionary) unknownApps.valueForKey(unknownAppKey);
                if (appDict != null) {
                    NSArray appDictKeys = appDict.allKeys();
                    for (Enumeration e2 = appDictKeys.objectEnumerator(); e2.hasMoreElements(); ) {
                        String appDictKey = (String) e2.nextElement();
                        NSTimestamp lastLifebeat = (NSTimestamp) appDict.valueForKey(appDictKey);
                        if ( (lastLifebeat != null) && (lastLifebeat.before(cutOffDate)) ) {
                            appDict.removeObjectForKey(appDictKey);
                        }
                    }
                    if (appDict.count() == 0) {
                        unknownApps.removeObjectForKey(unknownAppKey);
View Full Code Here

TOP

Related Classes of com.webobjects.foundation.NSTimestamp

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.