Example usage for java.lang InterruptedException printStackTrace

List of usage examples for java.lang InterruptedException printStackTrace

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:com.foxykeep.datadroid.internal.network.NetworkConnectionImplF.java

private static String convertStreamToString(InputStream is, boolean isGzipEnabled, File file, Context con)
        throws IOException {
    InputStream cleanedIs = is;//from   ww w  .  j a  v  a  2 s .  c o m
    if (isGzipEnabled) {
        cleanedIs = new GZIPInputStream(is);
    }
    FileOutputStream fos = null;

    final SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(con.getApplicationContext());

    final SimpleWrapper downloaded = new SimpleWrapper();
    final Editor ed = sp.edit();
    final String path = "DL" + file.getParentFile().getName();

    class MyThread extends Thread {

        volatile boolean finished = false;

        public void stopMe() {
            finished = true;
        }

        @Override
        public void run() {
            while (!finished) {
                ed.putLong(path, downloaded.dl);
                ed.commit();
                try {
                    Thread.sleep(100);

                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }

        }
    }
    ;
    final MyThread thread = new MyThread();
    try {
        fos = new FileOutputStream(file);
        byte[] buffer = new byte[8192];
        int len1 = 0;

        thread.start();
        while ((len1 = cleanedIs.read(buffer)) != -1) {
            fos.write(buffer, 0, len1);
            downloaded.dl += len1;
        }
        ed.putLong(path, downloaded.dl);
        ed.commit();

        fos.flush();
    } catch (IOException e) {
        throw e;
    } finally {
        thread.stopMe();
        if (fos != null) {
            fos.close();
        }
        cleanedIs.close();
        if (isGzipEnabled) {
            is.close();
        }
    }

    return "";
}

From source file:FactFind.PersonalDetails.java

public static boolean CustomerPersonalDetails() {

    int MaxCustomerreached = 0;
    JSONArray CustomerInformation_Array = (JSONArray) TestExecution.JSONTestData.get("Customerinformation");
    Iterator<JSONObject> CustomerInformationArray = CustomerInformation_Array.iterator();

    String FirstCustomerFlag = "Yes";
    try {//  ww w.j a  v  a  2 s  .  c  o  m

        WebDriverWait wait = new WebDriverWait(driver, 30);
        wait.until(ExpectedConditions.elementToBeClickable(NextButtonTopofthePage));

        while (CustomerInformationArray.hasNext()) {
            if (MaxCustomerreached >= 2) {
                break;
            }

            JSONObject CustomerInformation = CustomerInformationArray.next();

            if ((FirstCustomerFlag.equals("Yes") || CustomerInformation.get("IsApplicant").equals("Yes"))
                    && CustomerInformation.get("CustomerType").equals("Individual")) {

                if (FirstCustomerFlag.equals("Yes")) {
                    Applicant1.click();
                    Thread.sleep(3000);
                    MaxCustomerreached++;
                } else if (CustomerInformation.get("IsApplicant").equals("Yes")) {
                    Applicant2.click();
                    Thread.sleep(3000);
                    MaxCustomerreached++;
                }

                if (JSON.GetTestData(CustomerInformation, "CustomerNames").get("Title") != null
                        && Integer.parseInt(JSON.GetTestData(CustomerInformation, "CustomerNames").get("Title")
                                .toString()) >= 1) {
                    Title.click();
                    Helper.Keystrokeup(9);
                    Helper.Keystrokedown(Integer.parseInt(
                            JSON.GetTestData(CustomerInformation, "CustomerNames").get("Title").toString()));
                }

                if (JSON.GetTestData(CustomerInformation, "CustomerNames").get("MiddleName") != null) {
                    MiddleName.click();
                    MiddleName.clear();
                    MiddleName.sendKeys(JSON.GetTestData(CustomerInformation, "CustomerNames").get("MiddleName")
                            .toString());
                }

                if (CustomerInformation.get("Gender") != null) {
                    if (CustomerInformation.get("Gender").equals("Male")
                            || CustomerInformation.get("Gender").equals("Female")) {
                        Gender.click();
                        Gender.sendKeys(CustomerInformation.get("Gender").toString());
                        Helper.Keystrokeenter(1);
                    } else {
                        Gender.click();
                        Gender.sendKeys("Unspecified");
                        Helper.Keystrokeenter(1);
                    }
                }

                if (CustomerInformation.get("DOB") != null) {
                    if (FirstCustomerFlag.equals("Yes")) {
                        DateOfbirth.click();
                        DateOfbirth.clear();
                        DateOfbirth.sendKeys(CustomerInformation.get("DOB").toString());
                    } else if (CustomerInformation.get("IsApplicant").equals("Yes")) {
                        DateOfbirthSpouse.click();
                        DateOfbirthSpouse.clear();
                        DateOfbirthSpouse.sendKeys(CustomerInformation.get("DOB").toString());
                    }
                }

                if (CustomerInformation.get("ResidentialStatus") != null
                        && Integer.parseInt(CustomerInformation.get("ResidentialStatus").toString()) >= 1) {
                    if (Integer.parseInt(CustomerInformation.get("ResidentialStatus").toString()) == 1
                            || Integer.parseInt(CustomerInformation.get("ResidentialStatus").toString()) == 2
                            || Integer.parseInt(CustomerInformation.get("ResidentialStatus").toString()) == 3) {
                        ResidencyStatus.click();
                        Helper.Keystrokeup(3);
                        Helper.Keystrokedown(2);
                        Helper.Keystrokeenter(1);
                    } else if (Integer.parseInt(CustomerInformation.get("ResidentialStatus").toString()) == 4) {
                        ResidencyStatus.click();
                        Helper.Keystrokeup(3);
                        Helper.Keystrokedown(1);
                        Helper.Keystrokeenter(1);
                    } else if (Integer.parseInt(CustomerInformation.get("ResidentialStatus").toString()) == 5) {
                        ResidencyStatus.click();
                        Helper.Keystrokeup(3);
                        Helper.Keystrokedown(3);
                        Helper.Keystrokeenter(1);
                    }

                }

                if (JSON.GetTestData(CustomerInformation, "CustomerContactDetails").get("Mobile") != null) {
                    Mobile.click();
                    Mobile.clear();
                    Mobile.sendKeys(JSON.GetTestData(CustomerInformation, "CustomerContactDetails")
                            .get("Mobile").toString());
                }

                if (JSON.GetTestData(CustomerInformation, "CustomerContactDetails").get("HomePhone") != null) {
                    HomePhone.click();
                    HomePhone.clear();
                    HomePhone.sendKeys(JSON.GetTestData(CustomerInformation, "CustomerContactDetails")
                            .get("HomePhone").toString());
                }

                if (JSON.GetTestData(CustomerInformation, "CustomerContactDetails")
                        .get("BusinessPhone") != null) {
                    BusinessPhone.click();
                    BusinessPhone.clear();
                    BusinessPhone.sendKeys(JSON.GetTestData(CustomerInformation, "CustomerContactDetails")
                            .get("BusinessPhone").toString());
                }

                JSONObject FactFind = JSON.GetTestData(CustomerInformation, "FactFind");

                if (JSON.GetTestData(FactFind, "DriversLicense").get("DriversLicenceNumber") != null) {
                    DriversLicenceNumber.click();
                    DriversLicenceNumber.clear();
                    DriversLicenceNumber.sendKeys(JSON.GetTestData(FactFind, "DriversLicense")
                            .get("DriversLicenceNumber").toString());
                }

                if (JSON.GetTestData(FactFind, "DriversLicense").get("LicenseState") != null) {
                    LicenceState.click();
                    LicenceState.sendKeys(
                            JSON.GetTestData(FactFind, "DriversLicense").get("LicenseState").toString());
                    Helper.Keystrokeenter(1);
                }

                if (JSON.GetTestData(FactFind, "DriversLicense").get("LicenceIssued") != null) {
                    if (FirstCustomerFlag.equals("Yes")) {
                        LicenceIssued.click();
                        LicenceIssued.clear();
                        LicenceIssued.sendKeys(
                                JSON.GetTestData(FactFind, "DriversLicense").get("LicenceIssued").toString());
                    } else if (CustomerInformation.get("IsApplicant").equals("Yes")) {
                        LicenceIssuedSpouse.click();
                        LicenceIssuedSpouse.clear();
                        LicenceIssuedSpouse.sendKeys(
                                JSON.GetTestData(FactFind, "DriversLicense").get("LicenceIssued").toString());
                    }
                }

                if (JSON.GetTestData(FactFind, "DriversLicense").get("LicenceExpires") != null) {
                    if (FirstCustomerFlag.equals("Yes")) {
                        LicenceExpiry.click();
                        LicenceExpiry.clear();
                        LicenceExpiry.sendKeys(
                                JSON.GetTestData(FactFind, "DriversLicense").get("LicenceExpires").toString());
                    } else if (CustomerInformation.get("IsApplicant").equals("Yes")) {
                        LicenceExpirySpouse.click();
                        LicenceExpirySpouse.clear();
                        LicenceExpirySpouse.sendKeys(
                                JSON.GetTestData(FactFind, "DriversLicense").get("LicenceExpires").toString());
                    }
                }

                Thread.sleep(3000);

                if (JSON.GetTestData(CustomerInformation, "CustomerDependents")
                        .get("NumberOfDependents") != null) {
                    JSONArray DependantDOBArray = (JSONArray) JSON
                            .GetTestData(CustomerInformation, "CustomerDependents").get("DependentsDOB");
                    Iterator<String> DOBArray = DependantDOBArray.iterator();
                    while (DOBArray.hasNext()) {
                        Helper.ScroolToView(driver, AddDependant);
                        AddDependant.click();
                        Thread.sleep(2000);
                        AgeofDependant.sendKeys(CalculateAge(DOBArray.next().toString()));
                        Helper.ScroolToView(driver, SaveDependent);
                        SaveDependent.click();
                    }
                }

                FirstCustomerFlag = "No";
            }

        }
        Applicant1.click();
        Thread.sleep(5000);
        Helper.ScroolToView(driver, SaveMyDetails);
        SaveMyDetails.click();
        Thread.sleep(5000);
        Helper.ScroolToView(driver, NextButtonBottomofthePage);
        NextButtonBottomofthePage.click();
        Helper.ScreenDump(TestExecution.TestExecutionFolder, "FactFindPersonalDetails");
        logger.info("FactFind Customer personal details entered successfully");
        return true;

    } catch (InterruptedException e) {
        e.printStackTrace();
        logger.error(e.toString());
        Helper.ScreenDump(TestExecution.TestExecutionFolder, "Error");
        return false;
    }

}

From source file:FormatStorage1.MergeFileUtil1.java

public static void runold(String inputdir, String outputdir, Configuration conf) throws IOException {
    JobConf job = new JobConf(conf);
    job.setJobName("MergeFileUtil");
    job.setJarByClass(MergeFileUtil1.class);
    FileSystem fs = null;/*from www  .ja v a  2 s . c o m*/
    fs = FileSystem.get(job);
    if (fs.exists(new Path(outputdir))) {
        throw new IOException("outputdir: " + outputdir + " exist!!!");
    }

    FileStatus[] fss = fs.listStatus(new Path(inputdir));

    if (fss == null || fss.length <= 0) {
        throw new IOException("no input files");
    }

    for (FileStatus status : fss) {
        if (status.isDir()) {
            throw new IOException("!!!input dir contains directory:\t" + status.getPath().toString());
        }
    }

    IFormatDataFile ifdf = new IFormatDataFile(job);
    ifdf.open(fss[0].getPath().toString());
    job.set("ifdf.head.info", ifdf.fileInfo().head().toStr());
    ifdf.close();

    long wholesize = 0;
    for (FileStatus status : fss) {
        wholesize += status.getLen();
    }

    long fl = 512 * 1024 * 1024;
    int reduces = (int) (wholesize / fl + 1);
    job.setNumReduceTasks(reduces);

    FileInputFormat.setInputPaths(job, inputdir);
    FileOutputFormat.setOutputPath(job, new Path(outputdir));

    job.setOutputKeyClass(LongWritable.class);
    job.setOutputValueClass(IRecord.class);

    job.setMapperClass(MergeMap.class);
    job.setReducerClass(MergeReduce.class);

    job.setInputFormat(MergeIFormatInputFormat.class);
    job.setOutputFormat(MergeIFormatOutputFormat.class);

    JobClient jc = new JobClient(job);
    RunningJob rjob = jc.submitJob(job);
    try {

        String lastReport = "";
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss,SSS");
        long reportTime = System.currentTimeMillis();
        long maxReportInterval = 3 * 1000;

        while (!rjob.isComplete()) {
            Thread.sleep(1000);

            int mapProgress = Math.round(rjob.mapProgress() * 100);
            int reduceProgress = Math.round(rjob.reduceProgress() * 100);

            String report = " map = " + mapProgress + "%,  reduce = " + reduceProgress + "%";

            if (!report.equals(lastReport) || System.currentTimeMillis() >= reportTime + maxReportInterval) {

                String output = dateFormat.format(Calendar.getInstance().getTime()) + report;
                System.err.println(output);
                lastReport = report;
                reportTime = System.currentTimeMillis();
            }
        }
        LOG.info(rjob.getJobState());

    } catch (IOException e1) {
        e1.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:org.fireflow.BaseEnviroment4Junit.java

@AfterClass
public static void afterClass() {
    // ?//  ww w.  ja  va  2 s . c  om
    Scheduler scheduler = runtimeContext.getEngineModule(Scheduler.class, PROCESS_TYPE);
    boolean hasJobInSchedule = scheduler.hasJobInSchedule(runtimeContext);
    System.out.println();
    while (hasJobInSchedule) {
        System.out.print("...");
        try {
            Thread.currentThread().sleep(3 * 1000);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        hasJobInSchedule = scheduler.hasJobInSchedule(runtimeContext);
    }
    WorkflowSession session = WorkflowSessionFactory.createWorkflowSession(runtimeContext,
            FireWorkflowSystem.getInstance());

    WorkflowQuery<ProcessInstance> q4ProcInst = session.createWorkflowQuery(ProcessInstance.class,
            PROCESS_TYPE);
    List<ProcessInstance> processInstanceList = q4ProcInst.list();

    WorkflowQuery<ActivityInstance> q4ActInst = session.createWorkflowQuery(ActivityInstance.class,
            PROCESS_TYPE);
    q4ActInst.addOrder(Order.asc(ActivityInstanceProperty.PROCESS_INSTANCE_ID))
            .addOrder(Order.asc(ActivityInstanceProperty.STEP_NUMBER));
    List<ActivityInstance> activityInstanceList = q4ActInst.list();

    WorkflowQuery<Token> q4Token = session.createWorkflowQuery(Token.class, PROCESS_TYPE);
    q4Token.addOrder(Order.asc(TokenProperty.PROCESS_INSTANCE_ID))
            .addOrder(Order.asc(TokenProperty.STEP_NUMBER));
    List<Token> tokenList = q4Token.list();

    WorkflowQuery<Variable> q4Variable = session.createWorkflowQuery(Variable.class, PROCESS_TYPE);
    q4Variable.addOrder(Order.asc(VariableProperty.SCOPE_ID));
    List<Variable> variableList = q4Variable.list();

    WorkflowQuery<WorkItem> q4WorkItem = session.createWorkflowQuery(WorkItem.class, PROCESS_TYPE);
    q4WorkItem.addOrder(Order.asc(WorkItemProperty.ACTIVITY_INSTANCE_$_PROCESSS_ID))
            .addOrder(Order.asc(WorkItemProperty.ACTIVITY_INSTANCE_$_PROCESSINSTANCE_ID))
            .addOrder(Order.asc(WorkItemProperty.ACTIVITY_INSTANCE_$_ID));
    List<WorkItem> workItemList = q4WorkItem.list();

    WorkflowQuery<ScheduleJob> q4ScheduleJob = session.createWorkflowQuery(ScheduleJob.class, PROCESS_TYPE);
    q4ScheduleJob.addOrder(Order.asc(ScheduleJobProperty.PROCESS_ID))
            .addOrder(Order.asc(ScheduleJobProperty.ACTIVITY_INSTANCE_$_STEP_NUMBER));
    List<ScheduleJob> jobList = q4ScheduleJob.list();

    // //////////////////////////////////////////////////////////////////////////////////////////
    // //////////////////////////////////////////////////////////////////////////////////////////

    System.out.println("******************************************************");
    System.out.println("**********Process Instance Staroge Content***********");
    System.out.println("******************************************************");
    System.out.println("Id\t\tState\t\tName\t\tDisplayName\t\t");

    for (ProcessInstance procInst : processInstanceList) {
        System.out.print(procInst.getId());
        System.out.print("\t\t");
        System.out.print(procInst.getState().getDisplayName());
        System.out.print("\t\t");
        System.out.print(procInst.getName());
        System.out.print("\t\t");
        System.out.print(procInst.getDisplayName());

        System.out.println("\n");
    }

    System.out.println("******************************************************");
    System.out.println("**********Activity Instance Staroge Content***********");
    System.out.println("******************************************************");
    System.out.println("StepNumber\t\tState\t\tName\t\tDisplayName\t\tProcessInstanceId\t\tId\t\t");

    for (ActivityInstance actInst : activityInstanceList) {

        System.out.print(actInst.getStepNumber());

        System.out.print("\t\t");
        System.out.print(actInst.getState().getDisplayName());
        System.out.print("\t\t");
        System.out.print(actInst.getName());
        System.out.print("\t\t");
        System.out.print(actInst.getDisplayName());
        System.out.print("\t\t");

        System.out.print(actInst.getProcessInstanceId());
        System.out.print("\t\t");
        System.out.print(actInst.getId());
        System.out.println("\n");
    }

    System.out.println("******************************************************");
    System.out.println("**************Token Staroge Content*******************");
    System.out.println("******************************************************");
    System.out.println("StepNumber\tState\tNodeId\t\tOperationContext\t\tProcessId\t\tProcessInstanceId\t\tId");
    for (Token token : tokenList) {
        System.out.print(token.getStepNumber());
        System.out.print("\t");

        System.out.print(token.getState().getDisplayName());
        System.out.print("\t");

        System.out.print(token.getElementId());
        System.out.print("\t\t");
        System.out.print(token.getOperationContextName().name());
        System.out.print("\t\t");
        System.out.print(token.getProcessId());
        System.out.print("\t\t");
        System.out.print(token.getProcessInstanceId());
        System.out.print("\t\t");
        System.out.print(token.getId());

        System.out.println("\n");
    }

    System.out.println("******************************************************");
    System.out.println("**************Variable Staroge Content****************");
    System.out.println("******************************************************");
    System.out.println("ScopeId\t\tName\t\tDataType\t\tValue");

    for (Variable var : variableList) {
        System.out.print(var.getScopeId());
        System.out.print("\t\t");
        System.out.print(var.getName());
        System.out.print("\t\t");
        System.out.print(var.getDataType());
        System.out.print("\t\t");
        System.out.print(var.getValueAsString());
        System.out.println("\n");
    }

    System.out.println("******************************************************");
    System.out.println("**************WorkItem  Staroge Content  *************");
    System.out.println("******************************************************");
    System.out.println(
            "Name\t\tState\t\tOwner\t\tCreatedTime\t\tClaimedTime\t\tEndTime\t\tId\ttActivityInstanceId");

    for (WorkItem workItem : workItemList) {
        System.out.print(workItem.getActivityInstance().getDisplayName());
        System.out.print("\t\t");
        System.out.print(workItem.getState().getDisplayName());
        System.out.print("\t\t");
        System.out.print(workItem.getOwnerName());
        System.out.print("\t\t");
        System.out.print(workItem.getCreatedTime() == null ? "--" : formater.format(workItem.getCreatedTime()));
        System.out.print("\t\t");
        System.out.print(workItem.getClaimedTime() == null ? "--" : formater.format(workItem.getClaimedTime()));
        System.out.print("\t\t");
        System.out.print(workItem.getEndTime() == null ? "--" : formater.format(workItem.getEndTime()));
        System.out.print("\t\t");
        System.out.print(workItem.getId());
        System.out.print("\t\t");
        System.out.print(workItem.getActivityInstance().getId());
        System.out.println();
    }

    System.out.println("******************************************************");
    System.out.println("**************ScheduleJob Staroge Content*************");
    System.out.println("******************************************************");
    System.out.println(
            "Name\t\tTriggeredTimes\t\tLastestTriggeredTime\t\tState\t\tEndTime\t\tTiggerType\t\tTriggerExpression");

    for (ScheduleJob job : jobList) {
        System.out.print(job.getName());
        System.out.print("\t\t");
        System.out.print(job.getTriggeredTimes());
        System.out.print("\t\t");
        System.out.print(
                job.getLatestTriggeredTime() == null ? "--" : formater.format(job.getLatestTriggeredTime()));
        System.out.print("\t\t");
        System.out.print(job.getState().getDisplayName());
        System.out.print("\t\t");
        System.out.print(job.getEndTime() == null ? "--" : formater.format(job.getEndTime()));
        System.out.print("\t\t");
        System.out.print(job.getTriggerType());
        System.out.print("\t\t");
        System.out.print(job.getTriggerExpression());
        System.out.println();
    }
}

From source file:name.yumao.douyu.http.PlaylistDownloader.java

public static void go(/**final String name,*/
final String num) {
    //         PlaylistDownloader loader = new PlaylistDownloader("http://");
    ExecutorService service = Executors.newCachedThreadPool();

    //           GetList producer = new GetList();

    roomnum = num;/*from w  w  w.ja v a 2s  .com*/

    //           Down consumer = new Down();
    // final   String  id = "";
    service.execute(new Runnable() {
        public void run() {

            while (true) {

                //                              
                //                              ZhanqiApiVo vo = HttpClientFromZhanqi.QueryZhanqiDownloadUrl(inNum.getText() );

                try {
                    String url = HttpClientFromDouyu.getHTML5DownUrl(num);
                    if (!url.equals("")) {

                        //   
                        fetchsubPlaylist(new URL(url));
                    } else {
                        logger.info("error");
                        outFile = getPath();
                    }

                } catch (MalformedURLException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();

                }
                //                                 

                //                              }
                //   

                try {
                    Thread.sleep(5000);
                } catch (InterruptedException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

            }
        }

    });

    service.execute(new Runnable() {

        public void run() {

            while (true) {
                logger.info("down ......................");
                URL down = null;

                while (true) {
                    try {
                        down = basket.poll();
                        logger.debug("down:" + down);
                        if (down != null)
                            downloadInternal(down);
                        Thread.sleep(500);

                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }

                //download("outtest");
            }
        }

    });

}

From source file:net.yacy.cora.federate.opensearch.SRURSSConnector.java

public static Thread searchSRURSS(final BlockingQueue<RSSMessage> queue, final String urlBase,
        final String query, final long timeoutInit, final int maximumRecordsInit, final CacheStrategy verify,
        final boolean global, final ClientIdentification.Agent agent) {
    final Thread job = new Thread("searchSRURSS:" + urlBase) {
        @Override/*  w  w w .  j a v a 2s .c o m*/
        public void run() {
            int startRecord = 0;
            RSSMessage message;
            int maximumRecords = maximumRecordsInit;
            long timeout = timeoutInit;
            mainloop: while (timeout > 0 && maximumRecords > 0) {
                final long st = System.currentTimeMillis();
                RSSFeed feed;
                try {
                    feed = loadSRURSS(urlBase, query, startRecord, recordsPerSession, verify, global, agent);
                } catch (final IOException e1) {
                    break mainloop;
                }
                if (feed == null || feed.isEmpty())
                    break mainloop;
                maximumRecords -= feed.size();
                innerloop: while (!feed.isEmpty()) {
                    message = feed.pollMessage();
                    if (message == null)
                        break innerloop;
                    try {
                        queue.put(message);
                    } catch (final InterruptedException e) {
                        break innerloop;
                    }
                }
                startRecord += recordsPerSession;
                timeout -= System.currentTimeMillis() - st;
            }
            try {
                queue.put(RSSMessage.POISON);
            } catch (final InterruptedException e) {
                e.printStackTrace();
            }
        }
    };
    job.start();
    return job;
}

From source file:com.github.rosjava_catkin_package_a.ARLocROS.ARLoc.java

private static CameraParams getCameraInfo(ConnectedNode connectedNode, Parameter parameter) {// Subscribe
    // to/*from  ww  w  .  j  a  v a  2s .  c o m*/
    // camera
    // info
    Subscriber<CameraInfo> subscriberToCameraInfo = connectedNode.newSubscriber(parameter.cameraInfoTopic(),
            CameraInfo._TYPE);
    final CameraInfoService cameraInfoService = CameraInfoService.create(subscriberToCameraInfo);
    Optional<CameraParams> cameraParamsOptional = cameraInfoService.getCameraParams();
    while (!cameraParamsOptional.isPresent()) {
        // we're not gonna do anything before getting the camera info
        try {
            TimeUnit.MILLISECONDS.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        cameraParamsOptional = cameraInfoService.getCameraParams();
    }
    return cameraParamsOptional.get();
}

From source file:com.utdallas.s3lab.smvhunter.enumerate.UIEnumerator.java

/**
 * Generate a click event//from  w  w w. j  a va  2  s .co  m
 * @param emulator
 * @param apkName
 * @param b
 * @param point
 * @return
 * @throws IOException
 */
public static synchronized String taptap(String emulator, int x, int y, String apkName, boolean sleep)
        throws IOException {
    if (sleep)
        if (logDebug)
            logger.debug(NetworkMonitor.getStringforPrinting("before tap log::", System.currentTimeMillis(),
                    apkName, emulator));
    String out = execCommand(String.format("%s input tap %d %d", emulator, x, y));
    try {
        if (sleep) {
            Thread.sleep(1000);
        }
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    if (sleep)
        if (logDebug)
            logger.debug(NetworkMonitor.getStringforPrinting("after tap log::", System.currentTimeMillis(),
                    apkName, emulator));
    return out;
}

From source file:org.pentaho.support.cmd.CommandLineUtility.java

/**
 * loads the supportutil.xml file and creates instance of selected retriever
 * and executes//  w ww  . j a v a 2 s  .c  om
 * 
 * @param args
 * @param server
 */
private static void executeService(String[] args, String server) {

    final Properties prop = loadSupportProperty();

    // if installation is manual and server is bi-server read web.xml
    if (getInstallationType() == 3 && getServer() == 1) {
        if (prop.getProperty(CMDConstant.BI_TOM_PATH) == null) {
            System.out.println(CMDConstant.ERROR_12);
            System.exit(0);
        } else {

            WEB_XML = new StringBuilder();
            WEB_XML.append(prop.getProperty(CMDConstant.BI_TOM_PATH)).append(File.separator)
                    .append(CMDConstant.WEB_APP).append(File.separator).append(CMDConstant.PENTAHO)
                    .append(File.separator).append(CMDConstant.WEB_INF).append(File.separator)
                    .append(CMDConstant.WEB_XML);

            PENTAHO_SOLU_PATH = getSolutionPath(server, WEB_XML.toString());
            prop.put(CMDConstant.PENTAHO_SOLU_PATH, PENTAHO_SOLU_PATH);
            prop.put(CMDConstant.BI_PATH, PENTAHO_SOLU_PATH);
        }

    } else if (getInstallationType() == 3 && getServer() == 2) {
        // if installation is manual and server is di-server read web.xml
        if (prop.getProperty(CMDConstant.DI_TOM_PATH) == null) {
            System.out.println(CMDConstant.ERROR_22);
            System.exit(0);
        } else {

            WEB_XML = new StringBuilder();
            WEB_XML.append(prop.getProperty(CMDConstant.DI_TOM_PATH)).append(File.separator)
                    .append(CMDConstant.WEB_APP).append(File.separator).append(CMDConstant.PENTAHO_DI)
                    .append(File.separator).append(CMDConstant.WEB_INF).append(File.separator)
                    .append(CMDConstant.WEB_XML);

            PENTAHO_SOLU_PATH = getSolutionPath(server, WEB_XML.toString());
            prop.put(CMDConstant.PENTAHO_SOLU_PATH, PENTAHO_SOLU_PATH);
            prop.put(CMDConstant.BI_PATH, PENTAHO_SOLU_PATH);
        }
    }

    if (getServer() == 1) {

        if (prop.get(CMDConstant.BI_PATH) == null) {

            System.out.println(CMDConstant.ERROR_1);
            System.exit(0);
        }
        if (prop.get(CMDConstant.BI_TOM_PATH) == null) {

            System.out.println(CMDConstant.ERROR_12);
            System.exit(0);
        } else {
            setBIServerPath(prop);
        }

    } else if (getServer() == 2) {
        if (prop.get(CMDConstant.DI_PATH) == null) {
            System.out.println(CMDConstant.ERROR_2);
            System.exit(0);
        }
        if (prop.get(CMDConstant.DI_TOM_PATH) == null) {
            System.out.println(CMDConstant.ERROR_22);
            System.exit(0);
        } else {
            setDIServerPath(prop);
        }
    }

    ApplicationContext context = new ClassPathXmlApplicationContext(CMDConstant.SPRING_FILE_NAME);
    factory = (CofingRetrieverFactory) context.getBean(CMDConstant.COFINGRETRIEVERACTORY);
    ConfigRetreiver[] config = factory.getConfigRetrevier(args);

    ExecutorService service = Executors.newFixedThreadPool(10);
    // loop for all created instance and call respective retriever
    for (final ConfigRetreiver configobj : config) {

        if (getServer() == 1) {

            configobj.setBISeverPath(prop);
            configobj.setServerName("biserver");
        } else if (getServer() == 2) {

            configobj.setDIServerPath(prop);
            configobj.setServerName("diserver");
        }

        if (getInstallationType() == 1) {

            // if installation is installer set Installer
            configobj.setInstallType("Installer");
        } else if (getInstallationType() == 2) {

            // if installation is Archive set Archive
            configobj.setInstallType("Archive");
        } else if (getInstallationType() == 3) {

            // if installation is Manual set Manual
            configobj.setInstallType("Manual");
        }

        // if instance if fileretriever sets required detail
        if (configobj instanceof FileRetriever) {

            configobj.setBidiXml(serverXml);
            configobj.setBidiBatFile(serverBatFile);
            configobj.setBidiProrperties(serverProrperties);
            configobj.setTomcatXml(tomcatXml);
        }

        service.execute(new Runnable() {
            public void run() {
                configobj.readAndSaveConfiguration(prop);
            }
        });

    }

    try {
        service.shutdown();
        Thread.sleep(60000);

        // call for zip
        if (SupportZipUtil.zipFile(prop)) {

            File file = new File(prop.getProperty(CMDConstant.SUPP_INFO_DEST_PATH) + File.separator
                    + prop.getProperty(CMDConstant.SUPP_INF_DIR));
            if (file.exists()) {
                // call for delete empty directory
                delete(file);
                System.exit(0);
            }
        }
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

From source file:de.rwth.dbis.acis.bazaar.service.TestBase.java

/**
 * Called before the tests start.//from   ww  w. ja va2  s.c  o  m
 * 
 * Sets up the node and initializes connector and users that can be used
 * throughout the tests.
 * 
 * @throws Exception
 */
public static void startServer() throws Exception {

    // start node
    node = LocalNode.newNode();
    node.storeAgent(testAgent);
    node.launch();

    ServiceAgent testService = ServiceAgent.generateNewAgent(testServiceClass, "a pass");
    testService.unlockPrivateKey("a pass");

    node.registerReceiver(testService);

    // start connector
    logStream = new ByteArrayOutputStream();

    connector = new WebConnector(true, HTTP_PORT, false, 1000);
    connector.setSocketTimeout(10000);
    connector.setLogStream(new PrintStream(logStream));
    connector.start(node);
    Thread.sleep(1000); // wait a second for the connector to become ready
    connector.updateServiceList();
    // avoid timing errors: wait for the repository manager to get all
    // services before continuing
    try {
        System.out.println("waiting..");
        Thread.sleep(10000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

}