Example usage for java.io EOFException getLocalizedMessage

List of usage examples for java.io EOFException getLocalizedMessage

Introduction

In this page you can find the example usage for java.io EOFException getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:org.apache.hadoop.hdfs.server.datanode.BPServiceActor.java

/**
* Register one bp with the corresponding NameNode
* <p/>//from w  w  w . j  a  v a 2 s.  co m
* The bpDatanode needs to register with the namenode on startup in order
* 1) to report which storage it is serving now and
* 2) to receive a registrationID
* <p/>
* issued by the namenode to recognize registered datanodes.
* 
* @param nsInfo current NamespaceInfo
* @see FSNamesystem#registerDatanode(DatanodeRegistration)
* @throws IOException
* @see FSNamesystem#registerDatanode(DatanodeRegistration)
*/
void register(NamespaceInfo nsInfo) throws IOException {
    // The handshake() phase loaded the block pool storage
    // off disk - so update the bpRegistration object from that info
    bpRegistration = bpos.createRegistration();

    while (shouldRun()) {
        try {
            // Use returned registration from namenode with updated fields
            bpRegistration = bpNamenode.registerDatanode(bpRegistration);
            bpRegistration.setNamespaceInfo(nsInfo);
            break;
        } catch (EOFException e) { // namenode might have just restarted
            LOG.info("Problem connecting to server: " + nnAddr + " :" + e.getLocalizedMessage());
            sleepAndLogInterrupts(1000, "connecting to server");
        } catch (SocketTimeoutException e) { // namenode is busy
            LOG.info("Problem connecting to server: " + nnAddr);
            sleepAndLogInterrupts(1000, "connecting to server");
        }
    }

    LOG.info("Block pool " + this + " successfully registered with NN");
    bpos.registrationSucceeded(this, bpRegistration);

    refreshNNConnections();

    // random short delay - helps scatter the BR from all DNs
    // block report only if the datanode is not already connected
    // to any other namenode.
    // In case of multiple actors (Multi NN)  we would like to 
    // send only one BR. 
    // potential race condition here. multiple actor might see that
    // none of the other actors are yet connected. to avoid such
    // scenarios we ask the first actor to do BR
    if (!bpos.otherActorsConnectedToNNs(this) && bpos.firstActor(this)) {
        bpos.scheduleBlockReport(dnConf.initialBlockReportDelay);
    } else {
        LOG.info("Block Report skipped as other BPServiceActors are connected to the namenodes ");
    }
}

From source file:com.alphabetbloc.accessmrs.services.SyncManager.java

public String readObsFile(File tempFile, SyncResult syncResult) {

    if (tempFile == null)
        return "error";

    try {/*  w ww .  j a  v a 2  s.co m*/

        DataInputStream dis = new DataInputStream(new FileInputStream(tempFile));

        if (dis != null) {
            DbProvider dbHelper = DbProvider.openDb();
            // open db and clean entries
            dbHelper.delete(DataModel.PATIENTS_TABLE, DataModel.KEY_CLIENT_CREATED + " IS NULL", null);
            dbHelper.delete(DataModel.OBSERVATIONS_TABLE, null, null);

            insertPatients(dis);
            addSyncStep(mContext.getString(R.string.sync_updating_data), false); // 70%
            insertObservations(dis);

            try {
                addSyncStep(mContext.getString(R.string.sync_updating_data), false); // 90%
                // (doubled
                // due
                // to
                // slow
                // speed)
                insertPatientForms(dis);
            } catch (EOFException e) {
                // do nothing for EOFExceptions in this case
                if (App.DEBUG)
                    Log.v(TAG, "No SmartForms available on server");
            }

            dis.close();
        }

        updateAccessMrsObs();
        addSyncStep(mContext.getString(R.string.sync_updating_data), false); // 100%

    } catch (Exception e) {
        e.printStackTrace();
        ++syncResult.stats.numIoExceptions;
        return e.getLocalizedMessage();
    }

    return null;
}