Example usage for java.lang Throwable Throwable

List of usage examples for java.lang Throwable Throwable

Introduction

In this page you can find the example usage for java.lang Throwable Throwable.

Prototype

public Throwable(Throwable cause) 

Source Link

Document

Constructs a new throwable with the specified cause and a detail message of (cause==null ?

Usage

From source file:org.apache.hadoop.hbase.procedure2.Procedure.java

/**
 * Called by the ProcedureExecutor on procedure-load to restore the latch state
 *///from  w w w  .  j av a  2s  .  c o m
@InterfaceAudience.Private
protected synchronized void incChildrenLatch() {
    // TODO: can this be inferred from the stack? I think so...
    this.childrenLatch++;
    if (LOG.isTraceEnabled()) {
        LOG.trace("CHILD LATCH INCREMENT " + this.childrenLatch, new Throwable(this.toString()));
    }
}

From source file:org.apache.hadoop.hbase.procedure2.Procedure.java

/**
 * Called by the ProcedureExecutor to notify that one of the sub-procedures has completed.
 *//*from ww  w .  ja v a  2 s.  c  om*/
@InterfaceAudience.Private
private synchronized boolean childrenCountDown() {
    assert childrenLatch > 0 : this;
    boolean b = --childrenLatch == 0;
    if (LOG.isTraceEnabled()) {
        LOG.trace("CHILD LATCH DECREMENT " + childrenLatch, new Throwable(this.toString()));
    }
    return b;
}

From source file:com.cloudera.api.model.ApiModelTest.java

@Test
public void testApiErrorMessage() throws Exception {
    Throwable cause = new Throwable("'cause.");
    Throwable t = new Throwable("To err is human...", cause);
    checkJsonXML(new ApiErrorMessage(t));
}

From source file:holidayiq.com.geofenced.geofence.GeofenceTransitionsIntentService.java

/**
 * Handles incoming intents./*from ww w .java2  s  . c  o  m*/
 *
 * @param intent sent by Location Services. This Intent is provided to Location
 *               Services (inside a PendingIntent) when addGeofences() is called.
 */
@Override
protected void onHandleIntent(Intent intent) {
    GeofencingEvent geofencingEvent = GeofencingEvent.fromIntent(intent);
    DBManager dbManager = new DBManager();
    if (geofencingEvent.hasError()) {
        String errorMessage = GeofenceErrorMessages.getErrorString(this, geofencingEvent.getErrorCode());
        HIQLog.e(TAG, errorMessage);
        HIQLog.d("geofence", "return::" + errorMessage);
        return;
    }
    int nearestDest = HIQSharedPrefrence.getInt("nearestLocationForDestination", this);
    String parentDestName = dbManager.getDestinationNamefromId(String.valueOf(nearestDest), this);

    // Get the transition type.
    int geofenceTransition = geofencingEvent.getGeofenceTransition();
    HIQLog.d("geofence", "" + geofenceTransition);
    if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER) {

        List<Geofence> triggeringGeofences = geofencingEvent.getTriggeringGeofences();

        String geoId = triggeringGeofences.get(0).getRequestId();
        //            if (triggeringGeofences.size() > 1)
        //                geoId = triggeringGeofences.get(1).getRequestId();
        String oId = geoId;
        if (oId.contains(":"))
            oId = oId.split(":")[1];

        if (geoId.equalsIgnoreCase(GeoFenceService.HOME_GEOFENCE_TAG_NAME)) {
            // show the home notification
            if (HIQSharedPrefrence.getBoolean("exited", getApplicationContext())) {
                SendNotificationForEntry(this, geoId, "home",
                        HIQSharedPrefrence.getString("entryGeoStringTitleHome", getApplicationContext()),
                        HIQSharedPrefrence.getString("entryGeoStringContentHome", getApplicationContext()),
                        HIQSharedPrefrence.getString("entryGeoStringDeeplinkHome", getApplicationContext()),
                        "Destination", getApplicationContext(), "Enter", false);
                HIQSharedPrefrence.putBoolean("exited", false, getApplicationContext());

            }
        } else if (geoId.startsWith("Hotel")) {
            String geoName = dbManager.getHotelNameForId(Integer.valueOf(oId));
            if (isDebug) {
                SendNotificationForEntry(this, oId, geoName,
                        " " + HIQSharedPrefrence.getString("entryGeoStringTitleHotel",
                                getApplicationContext()),
                        HIQSharedPrefrence.getString("entryGeoStringContentHotel", getApplicationContext()),
                        HIQSharedPrefrence.getString("entryGeoStringDeeplinkHotel", getApplicationContext()),
                        "Hotel", getApplicationContext(), "Enter", false);
            }
            logEvents(geoName, geoId, "Enter");
            try {
                GeoFenceDao dao = new GeoFenceDao(this);
                dao.open();
                dao.createRecord(Integer.parseInt(oId), "Hotel", "Enter", parentDestName,
                        String.valueOf(nearestDest), geoName, getApplicationContext());
                dao.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (geoId.startsWith("SS")) {
            String geoName = dbManager.getSSNameForId(Integer.valueOf(oId));
            if (isDebug) {
                SendNotificationForEntry(this, oId, geoName,
                        " " + HIQSharedPrefrence.getString("entryGeoStringTitleSS", getApplicationContext()),
                        HIQSharedPrefrence.getString("entryGeoStringContentSS", getApplicationContext()),
                        HIQSharedPrefrence.getString("entryGeoStringDeeplinkSS", getApplicationContext()), "SS",
                        getApplicationContext(), "Enter", false);
            }
            //logEvents(geoName,geoId,"Enter");
            try {
                GeoFenceDao dao = new GeoFenceDao(this);
                dao.open();
                dao.createRecord(Integer.parseInt(oId), "SS", "Enter", parentDestName,
                        String.valueOf(nearestDest), geoName, getApplicationContext());
                dao.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (geoId.equalsIgnoreCase(GeoFenceService.DYNAMIC_GEOFENCE_TAG_NAME)) {
            if (isDebug) {
                SendNotificationForEntry(this, geoId, "geofence entered", " Dynamic circle entered",
                        HIQSharedPrefrence.getString("entryGeoStringContentHome", getApplicationContext()),
                        HIQSharedPrefrence.getString("entryGeoStringDeeplinkHome", getApplicationContext()),
                        "Destination", getApplicationContext(), "Enter", false);
            }
            try {
                GeoFenceDao dao = new GeoFenceDao(this);
                dao.open();
                dao.createRecord(nearestDest, "Destination", "Enter", parentDestName,
                        String.valueOf(nearestDest), parentDestName, getApplicationContext());
                dao.close();
            } catch (Exception e) {
                e.printStackTrace();
            }

            //logEvents("DynamicCircle",geoId,"Enter");
        }

    } else if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_EXIT) {

        // Get the geofences that were triggered. A single event can trigger multiple geofences.
        List<Geofence> triggeringGeofences = geofencingEvent.getTriggeringGeofences();

        //first is always home
        String geoId = triggeringGeofences.get(0).getRequestId();
        String oId = geoId;
        if (oId.contains(":"))
            oId = oId.split(":")[1];
        //String name = dbManager.getGeoDestinationName(oId);

        //            if ((!(geoId.startsWith("Hotel") || geoId.startsWith("SS"))) && (!geoId.equals("-1"))) {
        //                RepopulateDestinationGeoFences();
        //                HIQSharedPrefrence.putString("enteredDestinationId", "-1", getApplicationContext());
        //            }
        //            if (geoId.equals("-1")) {
        //                HIQSharedPrefrence.putBoolean("exited", true, getApplicationContext());
        //            }

        if (geoId.equalsIgnoreCase(GeoFenceService.HOME_GEOFENCE_TAG_NAME)) {
            // show the home notification
            HIQSharedPrefrence.putBoolean("exited", true, getApplicationContext());
            //logEvents("Home",geoId,"Exit");
        } else if (geoId.startsWith("Hotel")) {
            String geoName = dbManager.getHotelNameForId(Integer.valueOf(oId));
            if (isDebug) {
                SendNotificationForEntry(this, oId, geoName,
                        "? " + HIQSharedPrefrence.getString("entryGeoStringTitleHotel",
                                getApplicationContext()),
                        HIQSharedPrefrence.getString("entryGeoStringContentHotel", getApplicationContext()),
                        HIQSharedPrefrence.getString("entryGeoStringDeeplinkHotel", getApplicationContext()),
                        "Hotel", getApplicationContext(), "Exit", false);
            }
            //logEvents(geoName,geoId,"Exit");
            try {
                GeoFenceDao dao = new GeoFenceDao(this);
                dao.open();
                dao.createRecord(Integer.parseInt(oId), "Hotel", "Exit", parentDestName,
                        String.valueOf(nearestDest), geoName, getApplicationContext());
                dao.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (geoId.startsWith("SS")) {
            String geoName = dbManager.getSSNameForId(Integer.valueOf(oId));
            if (isDebug) {
                SendNotificationForEntry(this, oId, geoName,
                        "? " + HIQSharedPrefrence.getString("entryGeoStringTitleSS", getApplicationContext()),
                        HIQSharedPrefrence.getString("entryGeoStringContentSS", getApplicationContext()),
                        HIQSharedPrefrence.getString("entryGeoStringDeeplinkSS", getApplicationContext()), "SS",
                        getApplicationContext(), "Exit", false);
            }
            //logEvents(geoName,geoId,"Exit");
            try {
                GeoFenceDao dao = new GeoFenceDao(this);
                dao.open();
                dao.createRecord(Integer.parseInt(oId), "SS", "Exit", parentDestName,
                        String.valueOf(nearestDest), geoName, getApplicationContext());
                dao.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (geoId.equalsIgnoreCase(GeoFenceService.DYNAMIC_GEOFENCE_TAG_NAME)) {
            if (isDebug) {
                SendNotificationForEntry(this, geoId, "geofence exited", "? " + "Dynamic circle exited",
                        HIQSharedPrefrence.getString("entryGeoStringContentHome", getApplicationContext()),
                        HIQSharedPrefrence.getString("entryGeoStringDeeplinkHome", getApplicationContext()),
                        "Destination", getApplicationContext(), "Exit", false);
            }
            //logEvents("DynamicCircle",geoId,"Exit");
            HIQLocationManager locmanager = new HIQLocationManager(getApplicationContext());
            locmanager.setLocationResponseHandler(new HIQLocationManager.LocationResponseHandler() {
                @Override
                public void onLocationAvailable(Location oLocation, boolean plausible) {
                    GeoFenceHelper.triggerGeoFence(getApplicationContext(), oLocation.getLatitude(),
                            oLocation.getLongitude());
                }

                @Override
                public void onLocationFailed() {

                }
            });

            locmanager.getLocationGps(false);
            try {
                GeoFenceDao dao = new GeoFenceDao(this);
                dao.open();
                dao.createRecord(nearestDest, "Destination", "Exit", parentDestName,
                        String.valueOf(nearestDest), parentDestName, getApplicationContext());
                dao.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }

    } else if ((geofenceTransition == Geofence.GEOFENCE_TRANSITION_DWELL)) {
        List<Geofence> triggeringGeofences = geofencingEvent.getTriggeringGeofences();
        String geoId = triggeringGeofences.get(0).getRequestId();
        String oId = geoId;
        if (oId.contains(":"))
            oId = oId.split(":")[1];
        if (geoId.equalsIgnoreCase(GeoFenceService.HOME_GEOFENCE_TAG_NAME)) {
            // show the home notification

        } else if (geoId.startsWith("Hotel")) {
            String geoName = dbManager.getHotelNameForId(Integer.valueOf(oId));
            String lastknownDwell = HIQSharedPrefrence.getString("lastknownDwell", getApplicationContext());
            String lastknownHotelDwellTime = HIQSharedPrefrence.getString("lastknownHotelDwellTime",
                    getApplicationContext());
            long lastknownHotelDwellTimeMill = 0;

            if (lastknownHotelDwellTime != null) {
                try {
                    lastknownHotelDwellTimeMill = Long.parseLong(lastknownHotelDwellTime);
                } catch (Exception e) {

                }
            }
            if (lastknownDwell != null && lastknownDwell.equalsIgnoreCase(geoName)) {
                // do nothing in the same dwell location
            } else {
                //if((System.currentTimeMillis()-lastknownHotelDwellTimeMill>60*60*1000)) {
                SendNotificationForEntry(this, oId, geoName,
                        HIQSharedPrefrence.getString("entryGeoStringTitleHotel", getApplicationContext()),
                        HIQSharedPrefrence.getString("entryGeoStringContentHotel", getApplicationContext()),
                        HIQSharedPrefrence.getString("entryGeoStringDeeplinkHotel", getApplicationContext()),
                        "Hotel", getApplicationContext(), "Dwell", true);
                HIQSharedPrefrence.putString("lastknownDwell", geoName, getApplicationContext());
                HIQSharedPrefrence.putString("lastknownHotelDwellTime", System.currentTimeMillis() + "",
                        getApplicationContext());
                // }
            }
            try {
                GeoFenceDao dao = new GeoFenceDao(this);
                dao.open();
                dao.createRecord(Integer.parseInt(oId), "Hotel", "Dwell", parentDestName,
                        String.valueOf(nearestDest), geoName, getApplicationContext());
                dao.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (geoId.startsWith("SS")) {
            String geoName = dbManager.getSSNameForId(Integer.valueOf(oId));
            String lastknownDwell = HIQSharedPrefrence.getString("lastknownDwell", getApplicationContext());
            if (lastknownDwell != null && lastknownDwell.equalsIgnoreCase(geoName)) {
                // do nothing in the same dwell location
            } else {
                SendNotificationForEntry(this, oId, geoName,
                        HIQSharedPrefrence.getString("entryGeoStringTitleSS", getApplicationContext()),
                        HIQSharedPrefrence.getString("entryGeoStringContentSS", getApplicationContext()),
                        HIQSharedPrefrence.getString("entryGeoStringDeeplinkSS", getApplicationContext()), "SS",
                        getApplicationContext(), "Dwell", false);
            }
            try {
                GeoFenceDao dao = new GeoFenceDao(this);
                dao.open();
                dao.createRecord(Integer.parseInt(oId), "SS", "Dwell", parentDestName,
                        String.valueOf(nearestDest), geoName, getApplicationContext());
                dao.close();
            } catch (Exception e) {
                e.printStackTrace();
            }
        } else if (geoId.equalsIgnoreCase(GeoFenceService.DYNAMIC_GEOFENCE_TAG_NAME)) {
            if (isDebug) {
                SendNotificationForEntry(this, geoId, "geofence dwelled", " Dynamic circle dwelled",
                        HIQSharedPrefrence.getString("entryGeoStringContentHome", getApplicationContext()),
                        HIQSharedPrefrence.getString("entryGeoStringDeeplinkHome", getApplicationContext()),
                        "Destination", getApplicationContext(), "Dwell", false);
            }
            try {
                if (nearestDest != 0 && nearestDest != -1) {

                    String lastKnownDest = HIQSharedPrefrence.getString(LAST_KNOWN_DESTINATION, this);
                    String homeDest = HIQSharedPrefrence.getString(GeoFenceService.HOME_DESTINATION, this);
                    if (lastKnownDest == null || lastKnownDest.isEmpty()
                            || !lastKnownDest.equalsIgnoreCase(parentDestName)) {
                        if (homeDest != null && !homeDest.isEmpty()
                                && homeDest.equalsIgnoreCase(parentDestName)) {
                            if (HIQSharedPrefrence.getBoolean("exited", getApplicationContext())) {
                                GeofenceTransitionsIntentService.SendNotificationForEntry(this,
                                        String.valueOf(nearestDest), "home",
                                        HIQSharedPrefrence.getString("entryGeoStringTitleHome",
                                                getApplicationContext()),
                                        HIQSharedPrefrence.getString("entryGeoStringContentHome",
                                                getApplicationContext()),
                                        HIQSharedPrefrence.getString("entryGeoStringDeeplinkHome",
                                                getApplicationContext()),
                                        "Destination", getApplicationContext(), "Enter", false);
                                HIQSharedPrefrence.putBoolean("exited", false, getApplicationContext());
                            }
                        } else {
                            GeofenceTransitionsIntentService.SendNotificationForEntry(this,
                                    String.valueOf(nearestDest), parentDestName,
                                    HIQSharedPrefrence.getString("entryGeoStringTitleDest",
                                            getApplicationContext()),
                                    HIQSharedPrefrence.getString("entryGeoStringContentDest",
                                            getApplicationContext()),
                                    HIQSharedPrefrence.getString("entryGeoStringDeeplinkDest",
                                            getApplicationContext()),
                                    "Destination", getApplicationContext(), "EnterNewDestination", false);
                        }

                        HIQSharedPrefrence.putString(LAST_KNOWN_DESTINATION, parentDestName, this);
                        try {
                            GeoFenceDao dao = new GeoFenceDao(this);
                            dao.open();
                            dao.createRecord(nearestDest, "Destination", "Dwell", parentDestName,
                                    String.valueOf(nearestDest), parentDestName, getApplicationContext());
                            dao.close();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                } else {
                    //log this event
                }
            } catch (Exception e) {
                ExceptionUtils.logException(e);
            }
        }
    } else {
        ExceptionUtils.logException(new Throwable("Geofence unknown transition " + geofenceTransition));
    }
}

From source file:org.apache.jmeter.samplers.SampleResult.java

public void setEndTime(long end) {
    endTime = end;//from  w  w  w .j  ava 2s. c om
    if (!startTimeStamp) {
        timeStamp = endTime;
    }
    if (startTime == 0) {
        log.error("setEndTime must be called after setStartTime", new Throwable("Invalid call sequence"));
        // TODO should this throw an error?
    } else {
        elapsedTime = endTime - startTime - idleTime;
    }
}

From source file:org.apache.jmeter.samplers.SampleResult.java

/**
 * Record the start time of a sample//w w  w .  j  a v  a  2  s . c  o  m
 *
 */
public void sampleStart() {
    if (startTime == 0) {
        setStartTime(currentTimeInMillis());
    } else {
        log.error("sampleStart called twice", new Throwable("Invalid call sequence"));
    }
}

From source file:org.apache.jmeter.samplers.SampleResult.java

/**
 * Record the end time of a sample and calculate the elapsed time
 *
 *//* w  w w  .  jav  a 2 s. c om*/
public void sampleEnd() {
    if (endTime == 0) {
        setEndTime(currentTimeInMillis());
    } else {
        log.error("sampleEnd called twice", new Throwable("Invalid call sequence"));
    }
}

From source file:org.apache.jmeter.samplers.SampleResult.java

/**
 * Pause a sample/*from  www .j  a va2s. co m*/
 *
 */
public void samplePause() {
    if (pauseTime != 0) {
        log.error("samplePause called twice", new Throwable("Invalid call sequence"));
    }
    pauseTime = currentTimeInMillis();
}

From source file:op.OPDE.java

private static boolean loadLocalProperties() {
    boolean success = false;
    Properties sysprops = System.getProperties();

    try {/*  w w w . ja  va  2s .  c o m*/
        FileInputStream in = new FileInputStream(new File(opwd + sep + AppInfo.fileConfig));
        Properties p = new Properties();
        p.load(in);
        localProps.putAll(p);
        p.clear();

        in.close();

        success = true;
    } catch (FileNotFoundException ex) {
        fatal(new Throwable(lang.getString("misc.msg.installation.error")));
        //            // Keine local.properties. Wir richten wohl gerade einen neuen Client ein.
        //
        //            FrmInit frame = new FrmInit();
        //            frame.setVisible(true);
        //            SYSTools.center(frame);

    } catch (IOException ex) {
        fatal(ex);
        //            System.exit(1);
    }
    return success;
}

From source file:org.apache.jmeter.samplers.SampleResult.java

/**
 * Resume a sample/*from   www  .  j  a va  2s.c o m*/
 *
 */
public void sampleResume() {
    if (pauseTime == 0) {
        log.error("sampleResume without samplePause", new Throwable("Invalid call sequence"));
    }
    idleTime += currentTimeInMillis() - pauseTime;
    pauseTime = 0;
}