Example usage for java.util.concurrent TimeoutException printStackTrace

List of usage examples for java.util.concurrent TimeoutException printStackTrace

Introduction

In this page you can find the example usage for java.util.concurrent TimeoutException printStackTrace.

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:org.rifidi.edge.adapter.awid.awid2010.AwidSession.java

@Override
protected TimeoutCommand getKeepAliveCommand() {
    return new TimeoutCommand("AWIDKeepAliveCommand") {

        @Override//from   ww w.  ja v  a2s  .c o m
        public void execute() throws TimeoutException {
            ReaderStatusCommand command = new ReaderStatusCommand();
            try {
                AwidSession session = (AwidSession) super.sensorSession;
                clearUndelieverdMessages();
                session.sendMessage(command);
                ByteMessage response = session.getEndpoint().receiveMessage(session.getTimeout());
                AckMessage ack = new AckMessage(response.message);

                response = session.getEndpoint().receiveMessage(session.getTimeout());
                ReaderStatusMessage status = new ReaderStatusMessage(response.message);

            } catch (TimeoutException ex) {
                ex.printStackTrace();
                throw ex;
            } catch (IOException e) {
                logger.warn("IOException on keepalive");
            }

        }
    };
}

From source file:at.alladin.rmbt.client.v2.task.HttpProxyTask.java

public QoSTestResult call() throws Exception {
    final QoSTestResult result = initQoSTestResult(QoSTestResultEnum.HTTP_PROXY);
    try {//  www .  j  a  v a  2s .  c o  m
        onStart(result);

        Future<QoSTestResult> httpTimeoutTask = RMBTClient.getCommonThreadPool()
                .submit(new Callable<QoSTestResult>() {

                    public QoSTestResult call() throws Exception {
                        httpGet(result);
                        return result;
                    }

                });

        final QoSTestResult testResult = httpTimeoutTask.get((int) (downloadTimeout / 1000000),
                TimeUnit.SECONDS);
        return testResult;
    } catch (TimeoutException e) {
        e.printStackTrace();
        result.getResultMap().put(RESULT_HASH, "TIMEOUT");
    } catch (Exception e) {
        throw e;
    } finally {
        onEnd(result);
    }

    return result;
}

From source file:org.rifidi.edge.adapter.awid.commands.awid2010.AwidReadBlockDataCommand.java

@Override
protected void execute() throws TimeoutException {
    AntennaSwitchCommand antennaSwitchCommand = new AntennaSwitchCommand(true);
    AntennaSourceCommand antennaCommand = new AntennaSourceCommand();
    Gen2ReadBlockDataCommand command = new Gen2ReadBlockDataCommand(this.memorybank);
    AwidSession session = (AwidSession) super.sensorSession;
    try {//from  w  ww  .j av  a 2s  . c  o m
        session.sendMessage(antennaSwitchCommand);
        ByteMessage response = session.getEndpoint().receiveMessage();
        AckMessage ack = new AckMessage(response.message);
        if (!ack.isSuccessful()) {
            logger.warn(antennaSwitchCommand + " was not successful");
        }

        session.sendMessage(antennaCommand);
        response = session.getEndpoint().receiveMessage();
        ack = new AckMessage(response.message);
        if (!ack.isSuccessful()) {
            logger.warn(antennaCommand + " was not successful");
        }
        session.sendMessage(command);
        ack = new AckMessage(response.message);
        if (!ack.isSuccessful()) {
            logger.warn(antennaCommand + " was not successful");
        }
        try {
            response = session.getEndpoint().receiveMessage();
            Gen2ReadBlockDataResponse data = new Gen2ReadBlockDataResponse(response.message, memorybank,
                    super.sensorSession.getSensor().getID());
            // TODO: put data in Esper
        } catch (TimeoutException e) {
            // Ignore timeout exceptions from this command since it only
            // returns once it has seen something.
        }
        session.sendMessage(new StopCommand());
        response = session.getEndpoint().receiveMessage();
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:com.tk.httpClientErp.initialcheck.InitialcheckDetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_firstinspectiondetail);
    fiId = getIntent().getStringExtra("id");
    mFiHashMap = MyStore.getBeanByParam(fiId, "id", MyStore.firstInspectionList);

    mId = (TextView) findViewById(R.id.fi_detail_id);
    mFiLicense = (TextView) findViewById(R.id.fi_license_detail);
    mXmName = (TextView) findViewById(R.id.fi_detail_xmName);
    busno = (TextView) findViewById(R.id.fi_bus_no);

    mId.setText(mFiHashMap.get("id").toString());
    mFiLicense.setText(mFiHashMap.get("license").toString());
    mXmName.setText(mFiHashMap.get("xmName").toString());
    busno.setText(mFiHashMap.get("bus_no").toString());

    mkqlqq = (CheckBox) findViewById(R.id.fi_kqlqq);
    mkqlqq.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("kqlqq"))));
    mkqlqq.setOnCheckedChangeListener(checkBoxCommon("kqlqq", mFiHashMap));

    mqblqq = (CheckBox) findViewById(R.id.fi_qblqq);
    mqblqq.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("qblqq"))));
    mqblqq.setOnCheckedChangeListener(checkBoxCommon("qblqq", mFiHashMap));

    mjjykg = (CheckBox) findViewById(R.id.fi_jjykg);
    mjjykg.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("jjykg"))));
    mjjykg.setOnCheckedChangeListener(checkBoxCommon("jjykg", mFiHashMap));

    mxyd = (CheckBox) findViewById(R.id.fi_xyd);
    mxyd.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("xyd"))));
    mxyd.setOnCheckedChangeListener(checkBoxCommon("xyd", mFiHashMap));

    msxg = (CheckBox) findViewById(R.id.fi_sxg);
    msxg.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("sxg"))));
    msxg.setOnCheckedChangeListener(checkBoxCommon("sxg", mFiHashMap));

    myxg = (CheckBox) findViewById(R.id.fi_yxg);
    myxg.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("yxg"))));
    myxg.setOnCheckedChangeListener(checkBoxCommon("yxg", mFiHashMap));

    mbyclg = (CheckBox) findViewById(R.id.fi_byclg);
    mbyclg.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("byclg"))));
    mbyclg.setOnCheckedChangeListener(checkBoxCommon("byclg", mFiHashMap));

    mdcj = (CheckBox) findViewById(R.id.fi_dcj);
    mdcj.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("dcj"))));
    mdcj.setOnCheckedChangeListener(checkBoxCommon("dcj", mFiHashMap));

    mzyb = (CheckBox) findViewById(R.id.fi_zyb);
    mzyb.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("zyb"))));
    mzyb.setOnCheckedChangeListener(checkBoxCommon("zyb", mFiHashMap));

    msjhl = (CheckBox) findViewById(R.id.fi_sjhl);
    msjhl.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("sjhl"))));
    msjhl.setOnCheckedChangeListener(checkBoxCommon("sjhl", mFiHashMap));

    msjhdb = (CheckBox) findViewById(R.id.fi_sjhdb);
    msjhdb.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("sjhdb"))));
    msjhdb.setOnCheckedChangeListener(checkBoxCommon("sjhdb", mFiHashMap));

    mdrz = (CheckBox) findViewById(R.id.fi_drz);
    mdrz.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("drz"))));
    mdrz.setOnCheckedChangeListener(checkBoxCommon("drz", mFiHashMap));

    msrz = (CheckBox) findViewById(R.id.fi_srz);
    msrz.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("srz"))));
    msrz.setOnCheckedChangeListener(checkBoxCommon("srz", mFiHashMap));

    mqdfbl = (CheckBox) findViewById(R.id.fi_qdfbl);
    mqdfbl.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("qdfbl"))));
    mqdfbl.setOnCheckedChangeListener(checkBoxCommon("qdfbl", mFiHashMap));

    mhdfbl = (CheckBox) findViewById(R.id.fi_hdfbl);
    mhdfbl.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("hdfbl"))));
    mhdfbl.setOnCheckedChangeListener(checkBoxCommon("hdfbl", mFiHashMap));

    mmfs = (CheckBox) findViewById(R.id.fi_mfs);
    mmfs.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("mfs"))));
    mmfs.setOnCheckedChangeListener(checkBoxCommon("mfs", mFiHashMap));

    mcxfs = (CheckBox) findViewById(R.id.fi_cxfs);
    mcxfs.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("cxfs"))));
    mcxfs.setOnCheckedChangeListener(checkBoxCommon("cxfs", mFiHashMap));

    mtccg = (CheckBox) findViewById(R.id.fi_tccg);
    mtccg.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("tccg"))));
    mtccg.setOnCheckedChangeListener(checkBoxCommon("tccg", mFiHashMap));

    msxz = (CheckBox) findViewById(R.id.fi_sxz);
    msxz.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("sxz"))));
    msxz.setOnCheckedChangeListener(checkBoxCommon("sxz", mFiHashMap));

    mygqjp = (CheckBox) findViewById(R.id.fi_ygqjp);
    mygqjp.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("ygqjp"))));
    mygqjp.setOnCheckedChangeListener(checkBoxCommon("ygqjp", mFiHashMap));

    mdlb = (CheckBox) findViewById(R.id.fi_dlb);
    mdlb.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("dlb"))));
    mdlb.setOnCheckedChangeListener(checkBoxCommon("dlb", mFiHashMap));

    mlban = (CheckBox) findViewById(R.id.fi_lban);
    mlban.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("lban"))));
    mlban.setOnCheckedChangeListener(checkBoxCommon("lban", mFiHashMap));

    mdfs = (CheckBox) findViewById(R.id.fi_dfs);
    mdfs.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("dfs"))));
    mdfs.setOnCheckedChangeListener(checkBoxCommon("dfs", mFiHashMap));

    mbzq = (CheckBox) findViewById(R.id.fi_bzq);
    mbzq.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("bzq"))));
    mbzq.setOnCheckedChangeListener(checkBoxCommon("bzq", mFiHashMap));

    mdd = (CheckBox) findViewById(R.id.fi_dd);
    mdd.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("dd"))));
    mdd.setOnCheckedChangeListener(checkBoxCommon("dd", mFiHashMap));

    mxdq = (CheckBox) findViewById(R.id.fi_xdq);
    mxdq.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("xdq"))));
    mxdq.setOnCheckedChangeListener(checkBoxCommon("xdq", mFiHashMap));

    mxdh = (CheckBox) findViewById(R.id.fi_xdh);
    mxdh.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("xdh"))));
    mxdh.setOnCheckedChangeListener(checkBoxCommon("xdh", mFiHashMap));

    mfwd = (CheckBox) findViewById(R.id.fi_fwd);
    mfwd.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("fwd"))));
    mfwd.setOnCheckedChangeListener(checkBoxCommon("fwd", mFiHashMap));

    mzxdq = (CheckBox) findViewById(R.id.fi_zxdq);
    mzxdq.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("zxdq"))));
    mzxdq.setOnCheckedChangeListener(checkBoxCommon("zxdq", mFiHashMap));

    mzxdh = (CheckBox) findViewById(R.id.fi_zxdh);
    mzxdh.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("zxdh"))));
    mzxdh.setOnCheckedChangeListener(checkBoxCommon("zxdh", mFiHashMap));

    mzdd = (CheckBox) findViewById(R.id.fi_zdd);
    mzdd.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("zdd"))));
    mzdd.setOnCheckedChangeListener(checkBoxCommon("zdd", mFiHashMap));

    mdcd = (CheckBox) findViewById(R.id.fi_dcd);
    mdcd.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("dcd"))));
    mdcd.setOnCheckedChangeListener(checkBoxCommon("dcd", mFiHashMap));

    pzd = (CheckBox) findViewById(R.id.fi_pzd);
    pzd.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("pzd"))));
    pzd.setOnCheckedChangeListener(checkBoxCommon("pzd", mFiHashMap));

    ddeng = (CheckBox) findViewById(R.id.fi_ddeng);
    ddeng.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("ddeng"))));
    ddeng.setOnCheckedChangeListener(checkBoxCommon("ddeng", mFiHashMap));

    xd = (CheckBox) findViewById(R.id.fi_xd);
    xd.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("xd"))));
    xd.setOnCheckedChangeListener(checkBoxCommon("xd", mFiHashMap));

    jyb = (CheckBox) findViewById(R.id.fi_jyb);
    jyb.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("jyb"))));
    jyb.setOnCheckedChangeListener(checkBoxCommon("jyb", mFiHashMap));

    dlbiao = (CheckBox) findViewById(R.id.fi_dlbiao);
    dlbiao.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("dlbiao"))));
    dlbiao.setOnCheckedChangeListener(checkBoxCommon("dlbiao", mFiHashMap));

    qyb = (CheckBox) findViewById(R.id.fi_qyb);
    qyb.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("qyb"))));
    qyb.setOnCheckedChangeListener(checkBoxCommon("qyb", mFiHashMap));

    swb = (CheckBox) findViewById(R.id.fi_swb);
    swb.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("swb"))));
    swb.setOnCheckedChangeListener(checkBoxCommon("swb", mFiHashMap));

    qybiao = (CheckBox) findViewById(R.id.fi_qybiao);
    qybiao.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("qybiao"))));
    qybiao.setOnCheckedChangeListener(checkBoxCommon("qybiao", mFiHashMap));

    lcb = (CheckBox) findViewById(R.id.fi_lcb);
    lcb.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("lcb"))));
    lcb.setOnCheckedChangeListener(checkBoxCommon("lcb", mFiHashMap));

    mhq = (CheckBox) findViewById(R.id.fi_mhq);
    mhq.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("mhq"))));
    mhq.setOnCheckedChangeListener(checkBoxCommon("mhq", mFiHashMap));

    cxbl = (CheckBox) findViewById(R.id.fi_cxbl);
    cxbl.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("cxbl"))));
    cxbl.setOnCheckedChangeListener(checkBoxCommon("cxbl", mFiHashMap));

    pxan = (CheckBox) findViewById(R.id.fi_pxan);
    pxan.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("pxan"))));
    pxan.setOnCheckedChangeListener(checkBoxCommon("pxan", mFiHashMap));

    dqkg = (CheckBox) findViewById(R.id.fi_dqkg);
    dqkg.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("dqkg"))));
    dqkg.setOnCheckedChangeListener(checkBoxCommon("dqkg", mFiHashMap));

    dzxsp = (CheckBox) findViewById(R.id.fi_dzxsp);
    dzxsp.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("dzxsp"))));
    dzxsp.setOnCheckedChangeListener(checkBoxCommon("dzxsp", mFiHashMap));

    tbx = (CheckBox) findViewById(R.id.fi_tbx);
    tbx.setChecked(BlToIntOrIntToBl.objToBl((mFiHashMap.get("tbx"))));
    tbx.setOnCheckedChangeListener(checkBoxCommon("tbx", mFiHashMap));

    // /*from ww  w .j  a v  a  2s.  c om*/
    mfirstInspectionButton = (Button) findViewById(R.id.firstInspection_button);
    mfirstInspectionButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            JSONObject fiInfoJsonObj = new JSONObject(mFiHashMap);
            params.add(new BasicNameValuePair("fiInfo", fiInfoJsonObj.toString()));
            try {
                final String reultString = HttpClientUtil.postRequest("/android.do?method=savefiDetail", params,
                        MyStore.sessionID);
                InitialcheckDetailActivity.this.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(InitialcheckDetailActivity.this,
                                HttpClientUtil.callBackSuccOrFail(reultString, "resualt"), Toast.LENGTH_SHORT)
                                .show();
                    }
                });
            } catch (TimeoutException e) {
                e.printStackTrace();
                InitialcheckDetailActivity.this.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(InitialcheckDetailActivity.this, MyStore.TIMEOUTLOGIN,
                                Toast.LENGTH_SHORT).show();
                    }
                });
            }
            InitialcheckDetailActivity.this.finish();
            if (HttpClientUtil.reSUCCorFAILE)
                MyStore.deletBeanById(fiId, "id", MyStore.firstInspectionList); // List
        }
    });
}

From source file:org.rifidi.edge.adapter.awid.commands.awid2010.AwidPortalIDCommand.java

@Override
protected void execute() throws TimeoutException {
    AntennaSwitchCommand antennaSwitchCommand = new AntennaSwitchCommand(true);
    AntennaSourceCommand antennaCommand = new AntennaSourceCommand();
    AntennaSwitchRateCommand switchRateCommand = new AntennaSwitchRateCommand((byte) 3, (byte) 3);
    AwidSession session = (AwidSession) super.sensorSession;
    AbstractAwidCommand portalIDCommand;
    if (useMask) {
        portalIDCommand = new Gen2PortalIDWithMaskCommand(this.packetLength, this.memoryBank, this.startingBit,
                this.maskLength, this.maskValue, this.qValue, this.timeout, this.repeat);
    } else {/*  ww  w  .  j av  a 2  s.  c o m*/
        portalIDCommand = new Gen2PortalIDCommand(calculateTimeOutByte(), (byte) 0x00);
    }
    session.getEndpoint().clearUndeliveredMessages();
    try {
        session.sendMessage(antennaSwitchCommand);
        ByteMessage response = session.getEndpoint().receiveMessage();
        AckMessage ack = new AckMessage(response.message);
        if (!ack.isSuccessful()) {
            logger.warn(antennaSwitchCommand + " was not successful");
        }

        session.sendMessage(antennaCommand);
        response = session.getEndpoint().receiveMessage();
        ack = new AckMessage(response.message);
        if (!ack.isSuccessful()) {
            logger.warn(antennaCommand + " was not successful");
        }

        session.sendMessage(switchRateCommand);
        response = session.getEndpoint().receiveMessage();
        ack = new AckMessage(response.message);
        if (!ack.isSuccessful()) {
            logger.warn(antennaCommand + " was not successful");
        }

        session.sendMessage(portalIDCommand);
        response = session.getEndpoint().receiveMessage();
        ack = new AckMessage(response.message);
        if (!ack.isSuccessful()) {
            logger.warn(portalIDCommand + " was not successful");
        }

        //receive tag reads
        response = session.getEndpoint().receiveMessage(calculateSessionTimeout());
        List<Gen2PortalIDResponse> responses = new LinkedList<Gen2PortalIDResponse>();

        //receive tag messages until we get a timeout
        while (!isCommandDone(response)) {
            Gen2PortalIDResponse tagResponse = new Gen2PortalIDResponse(response.message,
                    session.getSensor().getID(), true);
            responses.add(tagResponse);
            try {
                response = session.getEndpoint().receiveMessage(calculateSessionTimeout());
            } catch (TimeoutException e) {
                // Ignore this so we we are sure to collect the data we
                // already have.
                break;
            }
        }
        //put all tag reads into a single ReadCycle
        handleTags(responses);

    } catch (IOException e) {
        e.printStackTrace();
        logger.warn("PortalID Command did not complete because " + "there was a problem with the session: "
                + session);
    }

}

From source file:com.tk.httpClientErp.buscheck.BusDetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_checkbusdetail);
    mBusId = getIntent().getStringExtra("busID");
    mBusHaMap = MyStore.getBeanByParam(mBusId, "busID", MyStore.busList);

    mLicense = (TextView) findViewById(R.id.check_busdetail_license);
    mDeptName = (TextView) findViewById(R.id.check_busdetail_deptname);
    mLastCheckTime = (TextView) findViewById(R.id.check_busdetail_lastchecktime);
    mcheckMile = (TextView) findViewById(R.id.check_busdetail_mile);

    mcheckMile.setText(mBusHaMap.get("checkMile").toString());
    mLicense.setText(mBusHaMap.get("license").toString());
    mDeptName.setText(mBusHaMap.get("deptName").toString());
    mLastCheckTime.setText(mBusHaMap.get("securityCheckDate").toString());

    // checkbox//from  ww w .ja  va 2s  .  c  o m
    mFangXiangJi = (CheckBox) findViewById(R.id.check_busdetail_direction);
    mFangXiangJi.setChecked(BlToIntOrIntToBl.objToBl((mBusHaMap.get("direction"))));
    mFangXiangJi.setOnCheckedChangeListener(checkBoxCommon("direction", mBusHaMap));

    mZhiLaGan = (CheckBox) findViewById(R.id.check_busdetail_draglink);
    mZhiLaGan.setChecked(BlToIntOrIntToBl.objToBl((mBusHaMap.get("draglink"))));
    mZhiLaGan.setOnCheckedChangeListener(checkBoxCommon("draglink", mBusHaMap));

    mHengLaGan = (CheckBox) findViewById(R.id.check_busdetail_tierod);
    mHengLaGan.setChecked(BlToIntOrIntToBl.objToBl((mBusHaMap.get("tierod"))));
    mHengLaGan.setOnCheckedChangeListener(checkBoxCommon("tierod", mBusHaMap));

    mZhuanXiangJieBi = (CheckBox) findViewById(R.id.check_busdetail_knucklearm);
    mZhuanXiangJieBi.setChecked(BlToIntOrIntToBl.objToBl((mBusHaMap.get("knucklearm"))));
    mZhuanXiangJieBi.setOnCheckedChangeListener(checkBoxCommon("knucklearm", mBusHaMap));

    mSiLunZhiDong = (CheckBox) findViewById(R.id.check_busdetail_fourwheelbraking);
    mSiLunZhiDong.setChecked(BlToIntOrIntToBl.objToBl((mBusHaMap.get("fourwheelbraking"))));
    mSiLunZhiDong.setOnCheckedChangeListener(checkBoxCommon("fourwheelbraking", mBusHaMap));

    mQuCheZhiDong = (CheckBox) findViewById(R.id.check_busdetail_parkingbraking);
    mQuCheZhiDong.setChecked(BlToIntOrIntToBl.objToBl((mBusHaMap.get("parkingbraking"))));
    mQuCheZhiDong.setOnCheckedChangeListener(checkBoxCommon("parkingbraking", mBusHaMap));

    mQiBeng = (CheckBox) findViewById(R.id.check_busdetail_pump);
    mQiBeng.setChecked(BlToIntOrIntToBl.objToBl((mBusHaMap.get("pump"))));
    mQiBeng.setOnCheckedChangeListener(checkBoxCommon("pump", mBusHaMap));

    mQiLu = (CheckBox) findViewById(R.id.check_busdetail_gascircuit);
    mQiLu.setChecked(BlToIntOrIntToBl.objToBl((mBusHaMap.get("gascircuit"))));
    mQiLu.setOnCheckedChangeListener(checkBoxCommon("gascircuit", mBusHaMap));

    mQiPing = (CheckBox) findViewById(R.id.check_busdetail_airbottle);
    mQiPing.setChecked(BlToIntOrIntToBl.objToBl((mBusHaMap.get("airbottle"))));
    mQiPing.setOnCheckedChangeListener(checkBoxCommon("airbottle", mBusHaMap));

    mRanQiGuanDao = (CheckBox) findViewById(R.id.check_busdetail_gaspipeline);
    mRanQiGuanDao.setChecked(BlToIntOrIntToBl.objToBl((mBusHaMap.get("gaspipeline"))));
    mRanQiGuanDao.setOnCheckedChangeListener(checkBoxCommon("gaspipeline", mBusHaMap));

    mZhuKongFa = (CheckBox) findViewById(R.id.check_busdetail_maincontrolvalve);
    mZhuKongFa.setChecked(BlToIntOrIntToBl.objToBl((mBusHaMap.get("maincontrolvalve"))));
    mZhuKongFa.setOnCheckedChangeListener(checkBoxCommon("maincontrolvalve", mBusHaMap));

    mBanZhouLuoSi = (CheckBox) findViewById(R.id.check_busdetail_Halfshaftscrew);
    mBanZhouLuoSi.setChecked(BlToIntOrIntToBl.objToBl((mBusHaMap.get("Halfshaftscrew"))));
    mBanZhouLuoSi.setOnCheckedChangeListener(checkBoxCommon("Halfshaftscrew", mBusHaMap));

    mLunTaiLuoSi = (CheckBox) findViewById(R.id.check_busdetail_tyrewhorl);
    mLunTaiLuoSi.setChecked(BlToIntOrIntToBl.objToBl((mBusHaMap.get("tyrewhorl"))));
    mLunTaiLuoSi.setOnCheckedChangeListener(checkBoxCommon("tyrewhorl", mBusHaMap));

    mChuanDongZhouLuoSi = (CheckBox) findViewById(R.id.check_busdetail_Driveshaftscrews);
    mChuanDongZhouLuoSi.setChecked(BlToIntOrIntToBl.objToBl((mBusHaMap.get("Driveshaftscrews"))));
    mChuanDongZhouLuoSi.setOnCheckedChangeListener(checkBoxCommon("Driveshaftscrews", mBusHaMap));

    mZhongJianZhiJiaLuoSi = (CheckBox) findViewById(R.id.check_busdetail_middle_bracket_screws);
    mZhongJianZhiJiaLuoSi.setChecked(BlToIntOrIntToBl.objToBl((mBusHaMap.get("bracketScrews"))));
    mZhongJianZhiJiaLuoSi.setOnCheckedChangeListener(checkBoxCommon("bracketScrews", mBusHaMap));

    // ~
    mSingleCheckButton = (Button) findViewById(R.id.check_singleBus_button);
    mSingleCheckButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mBusHaMap.containsValue(true)) { // mapturefalse
                mBusHaMap.put("mResult", true);
            } else {
                mBusHaMap.put("mResult", false);
            }
            List<NameValuePair> params = new ArrayList<NameValuePair>();
            JSONObject busDetailJsonObj = new JSONObject(mBusHaMap);
            params.add(new BasicNameValuePair("busDetailInfo", busDetailJsonObj.toString()));
            try {
                final String reultString = HttpClientUtil.postRequest("/android.do?method=checkBusDetail",
                        params, MyStore.sessionID);
                BusDetailActivity.this.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(BusDetailActivity.this,
                                HttpClientUtil.callBackSuccOrFail(reultString, "resualt"), Toast.LENGTH_SHORT)
                                .show();
                    }
                });
            } catch (TimeoutException e) {
                BusDetailActivity.this.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        Toast.makeText(BusDetailActivity.this, MyStore.TIMEOUTLOGIN, Toast.LENGTH_SHORT).show();
                    }
                });
                e.printStackTrace();
            }
            BusDetailActivity.this.finish();
            if (HttpClientUtil.reSUCCorFAILE)
                MyStore.deletBeanById(mBusId, "busID", MyStore.busList); // List
        }
    });
}

From source file:org.apache.kylin.storage.hbase.util.StorageCleanupJob.java

private void cleanUnusedHBaseTables(Configuration conf) throws IOException {
    CubeManager cubeMgr = CubeManager.getInstance(KylinConfig.getInstanceFromEnv());
    // get all kylin hbase tables
    Connection conn = HBaseConnection.get(KylinConfig.getInstanceFromEnv().getStorageUrl());
    Admin hbaseAdmin = conn.getAdmin();/*from  www. ja v  a2 s  . c  o  m*/
    String tableNamePrefix = IRealizationConstants.SharedHbaseStorageLocationPrefix;
    HTableDescriptor[] tableDescriptors = hbaseAdmin.listTables(tableNamePrefix + ".*");
    List<String> allTablesNeedToBeDropped = new ArrayList<String>();
    for (HTableDescriptor desc : tableDescriptors) {
        String host = desc.getValue(IRealizationConstants.HTableTag);
        if (KylinConfig.getInstanceFromEnv().getMetadataUrlPrefix().equalsIgnoreCase(host)) {
            //only take care htables that belongs to self, and created more than 2 days
            allTablesNeedToBeDropped.add(desc.getTableName().getNameAsString());
        }
    }

    // remove every segment htable from drop list
    for (CubeInstance cube : cubeMgr.listAllCubes()) {
        for (CubeSegment seg : cube.getSegments()) {
            String tablename = seg.getStorageLocationIdentifier();
            if (allTablesNeedToBeDropped.contains(tablename)) {
                allTablesNeedToBeDropped.remove(tablename);
                logger.info("Exclude table " + tablename + " from drop list, as the table belongs to cube "
                        + cube.getName() + " with status " + cube.getStatus());
            }
        }
    }

    if (delete == true) {
        // drop tables
        ExecutorService executorService = Executors.newSingleThreadExecutor();
        for (String htableName : allTablesNeedToBeDropped) {
            FutureTask futureTask = new FutureTask(new DeleteHTableRunnable(hbaseAdmin, htableName));
            executorService.execute(futureTask);
            try {
                futureTask.get(deleteTimeout, TimeUnit.MINUTES);
            } catch (TimeoutException e) {
                logger.warn("It fails to delete htable " + htableName + ", for it cost more than "
                        + deleteTimeout + " minutes!");
                futureTask.cancel(true);
            } catch (Exception e) {
                e.printStackTrace();
                futureTask.cancel(true);
            }
        }
        executorService.shutdown();
    } else {
        System.out.println("--------------- Tables To Be Dropped ---------------");
        for (String htableName : allTablesNeedToBeDropped) {
            System.out.println(htableName);
        }
        System.out.println("----------------------------------------------------");
    }

    hbaseAdmin.close();
}

From source file:org.apache.kylin.tool.StorageCleanupJob.java

private void cleanUnusedHBaseTables(Configuration conf) throws IOException {
    CubeManager cubeMgr = CubeManager.getInstance(KylinConfig.getInstanceFromEnv());
    // get all kylin hbase tables
    try (HBaseAdmin hbaseAdmin = new HBaseAdmin(conf)) {
        String tableNamePrefix = IRealizationConstants.SharedHbaseStorageLocationPrefix;
        HTableDescriptor[] tableDescriptors = hbaseAdmin.listTables(tableNamePrefix + ".*");
        List<String> allTablesNeedToBeDropped = new ArrayList<String>();
        for (HTableDescriptor desc : tableDescriptors) {
            String host = desc.getValue(IRealizationConstants.HTableTag);
            if (KylinConfig.getInstanceFromEnv().getMetadataUrlPrefix().equalsIgnoreCase(host)) {
                //only take care htables that belongs to self, and created more than 2 days
                allTablesNeedToBeDropped.add(desc.getTableName().getNameAsString());
            }// w  w w  .  ja va2s  .  c om
        }

        // remove every segment htable from drop list
        for (CubeInstance cube : cubeMgr.listAllCubes()) {
            for (CubeSegment seg : cube.getSegments()) {
                String tablename = seg.getStorageLocationIdentifier();
                if (allTablesNeedToBeDropped.contains(tablename)) {
                    allTablesNeedToBeDropped.remove(tablename);
                    logger.info("Exclude table " + tablename + " from drop list, as the table belongs to cube "
                            + cube.getName() + " with status " + cube.getStatus());
                }
            }
        }

        if (delete == true) {
            // drop tables
            ExecutorService executorService = Executors.newSingleThreadExecutor();
            for (String htableName : allTablesNeedToBeDropped) {
                FutureTask futureTask = new FutureTask(new DeleteHTableRunnable(hbaseAdmin, htableName));
                executorService.execute(futureTask);
                try {
                    futureTask.get(deleteTimeout, TimeUnit.MINUTES);
                } catch (TimeoutException e) {
                    logger.warn("It fails to delete htable " + htableName + ", for it cost more than "
                            + deleteTimeout + " minutes!");
                    futureTask.cancel(true);
                } catch (Exception e) {
                    e.printStackTrace();
                    futureTask.cancel(true);
                }
            }
            executorService.shutdown();
        } else {
            System.out.println("--------------- Tables To Be Dropped ---------------");
            for (String htableName : allTablesNeedToBeDropped) {
                System.out.println(htableName);
            }
            System.out.println("----------------------------------------------------");
        }
    }
}

From source file:net.bpelunit.framework.control.ws.WebServiceHandler.java

/**
 * /*w  ww .  j  av a2  s .co  m*/
 * <p>
 * Handles one incoming HTTP request. The sequence is as follows:
 * </p>
 * <ul>
 * <li>Check incoming URL for the partner track name. If none, reject.</li>
 * <li>Find partner for the name. If none or partner has no activities,
 * reject.</li>
 * <li>Post incoming message with partner name to the runner. Wait for
 * answer.</li>
 * <li>Get incoming message from runner. Return message in HTTP Request.</li>
 * </ul>
 * 
 */
@Override
public void handle(String pathInContext, Request rawRequest, HttpServletRequest request,
        HttpServletResponse response) throws IOException {

    wsLogger.info("Incoming request for path " + pathInContext);

    if (!request.getMethod().equals(HttpMethods.POST)) {
        wsLogger.error("Got a non-POST request - rejecting message " + pathInContext);
        // no POST method
        // let default 404 handler handle this situation.
        return;
    }

    if (fRunner == null) {
        wsLogger.error("Not initialized - rejecting message for URL " + pathInContext);
        // let default 404 handler handle this situaton.
        return;
    }
    // find target according to path in context

    String partnerName = getPartnerName(pathInContext);
    wsLogger.debug("Supposed partner name for this request: " + partnerName);

    PartnerTrack key;
    try {
        key = fRunner.findPartnerTrackForName(partnerName);
        if (key.isDone()) {
            wsLogger.info(
                    "Partner track " + partnerName + " has already finished its execution: replying with 404");
            return;
        }
    } catch (PartnerNotFoundException e1) {
        // Let default 404 handler handle this situation
        wsLogger.info(e1.getMessage());
        wsLogger.info("Rejecting message with 404.");
        return;
    }

    wsLogger.debug("A partner was found for the target URL: " + key);

    wsLogger.debug("Request method is: " + request.getMethod());

    IncomingMessage iMessage = new IncomingMessage();
    iMessage.setMessage(request.getInputStream());

    try {
        wsLogger.debug("Posting incoming message to blackboard...");
        fRunner.putWSIncomingMessage(key, iMessage);

        wsLogger.debug("Waiting for framework to supply answer...");
        final OutgoingMessage m2 = fRunner.getWSOutgoingMessage(key);

        wsLogger.debug("Got answer from framework, now sending...");

        int code = m2.getCode();
        String body = m2.getMessageAsString();

        wsLogger.debug("Answer is:\n" + body);
        for (String option : m2.getProtocolOptionNames()) {
            response.addHeader(option, m2.getProtocolOption(option));
        }
        sendResponse(response, code, body);

        wsLogger.debug("Posting \"message sent\" to framework...");
        fRunner.putWSOutgoingMessageSent(m2);

        wsLogger.info("Done handling request, result OK. " + code);

    } catch (TimeoutException e) {
        wsLogger.error("Timeout while waiting for framework to supply answer to incoming message");
        wsLogger.error("This most likely indicates a bug in the framework.");
        wsLogger.error("Sending fault.");
        sendResponse(response, HTTP_INTERNAL_ERROR, BPELUnitUtil.generateGenericSOAPFault());
    } catch (InterruptedException e) {
        wsLogger.error("Interrupted while waiting for framework for incoming message or answer.");
        wsLogger.error("This most likely indicates another error occurred.");
        wsLogger.error("Sending fault.");
        sendResponse(response, HTTP_INTERNAL_ERROR, BPELUnitUtil.generateGenericSOAPFault());
    } catch (Exception e) {
        // Debugging only
        e.printStackTrace();
        return;
    }
}

From source file:com.oneops.ops.dao.PerfDataAccessor.java

/**
 * Inits the DAOs/connections//w w  w . ja v  a2s  .com
 */
public void init() {
    logger.info("PerfDataAccessor: " + ":" + clusterName + ":" + keyspaceName);
    ExecutorService executor = Executors.newSingleThreadExecutor();
    Future<String> future = executor.submit(this::connectToCluster);

    try {
        logger.info("Started connecting.. with timeOut " + TIMEOUT_IN_SECONDS);
        logger.info(future.get(TIMEOUT_IN_SECONDS, TimeUnit.SECONDS));
        logger.info("Finished connecting!");

    } catch (TimeoutException e) {
        logger.error("no cassandra hosts available - shutting down");
        throw new HectorException("TimeOut occured in getting the cassandra connection");
    } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (ExecutionException e) {
        e.printStackTrace();
    }

    executor.shutdownNow();
    initCluster();
}