Example usage for java.util.concurrent ExecutionException printStackTrace

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

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

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

Usage

From source file:foundme.uniroma2.it.professore.HomeActivity.java

public static void populateView(String[] result) {

    courses = new String[result.length];
    System.arraycopy(result, 0, courses, 0, result.length);
    ArrayList<String> listp = new ArrayList<String>();

    Collections.addAll(listp, courses);
    //creo l'adapter
    ArrayAdapter<String> adapter = new ArrayAdapter<String>(context, android.R.layout.simple_list_item_1,
            listp);//from   w  ww  .ja  va 2  s .c  om
    //inserisco i dati
    lvCourses.setAdapter(adapter);
    swipeView.setColorSchemeColors(0xff429874, 0xffffffff, 0xff429874, 0xffffffff);
    swipeView.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            swipeView.setRefreshing(true);
            (new Handler()).postDelayed(new Runnable() {
                @Override
                public void run() {
                    try {
                        getCourse(false);
                    } catch (ExecutionException e) {
                        e.printStackTrace();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    swipeView.setRefreshing(false);
                }
            }, 3000);
        }
    });

    lvCourses.setOnScrollListener(new AbsListView.OnScrollListener() {
        @Override
        public void onScrollStateChanged(AbsListView absListView, int i) {

        }

        @Override
        public void onScroll(AbsListView absListView, int firstVisibleItem, int visibleItemCount,
                int totalItemCount) {
            if (firstVisibleItem == 0)
                swipeView.setEnabled(true);
            else
                swipeView.setEnabled(false);
        }
    });

    lvCourses.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
        public boolean onItemLongClick(AdapterView parent, View view, int position, long id) {
            toEdit = courses[position];
            for (int j = 0; j < parent.getChildCount(); j++)
                parent.getChildAt(j).setBackgroundColor(Color.TRANSPARENT);

            view.setBackgroundColor(0xff429874);
            ((Activity) context).startActionMode(modeCallBack);
            viewList = view;
            return true;
        }
    });

    lvCourses.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (!courses[position].equalsIgnoreCase(Variables_it.NO_COURSE)) {
                Intent i = new Intent(context, CoursesActivity.class);
                i.putExtra(Variables_it.COURSE, courses[position]);
                i.putExtra(Variables_it.NAME, name);
                i.putExtra(Variables_it.ROOM, nfctest.getText().toString());
                context.startActivity(i);
            }
        }
    });
}

From source file:com.jolbox.benchmark.BenchmarkTests.java

/**
 * Helper function./*from w ww  .  j  a  va2  s . com*/
 *
 * @param threads
 * @param cpds
 * @param workDelay
 * @param doPreparedStatement 
 * @return time taken
 * @throws InterruptedException
 */
public static long startThreadTest(int threads, DataSource cpds, int workDelay, boolean doPreparedStatement)
        throws InterruptedException {
    CountDownLatch startSignal = new CountDownLatch(1);
    CountDownLatch doneSignal = new CountDownLatch(threads);

    ExecutorService pool = Executors.newFixedThreadPool(threads);
    ExecutorCompletionService<Long> ecs = new ExecutorCompletionService<Long>(pool);
    for (int i = 0; i <= threads; i++) { // create and start threads
        ecs.submit(new ThreadTesterUtil(startSignal, doneSignal, cpds, workDelay, doPreparedStatement));
    }

    startSignal.countDown(); // START TEST!
    doneSignal.await();
    long time = 0;
    for (int i = 0; i <= threads; i++) {
        try {
            time = time + ecs.take().get();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }
    pool.shutdown();
    return time;
}

From source file:org.apache.hadoop.hdfs.server.namenode.FSDirDeleteOp.java

private static boolean deleteTreeLevel(final FSNamesystem fsn, final String subtreeRootPath,
        final long subTreeRootID, final AbstractFileTree.FileTree fileTree, int level)
        throws TransactionContextException, IOException {
    ArrayList<Future> barrier = new ArrayList<>();

    for (final ProjectedINode dir : fileTree.getDirsByLevel(level)) {
        if (fileTree.countChildren(dir.getId()) <= BIGGEST_DELETABLE_DIR) {
            final String path = fileTree.createAbsolutePath(subtreeRootPath, dir);
            Future f = multiTransactionDeleteInternal(fsn, path, subTreeRootID);
            barrier.add(f);// w w  w. j a v a 2s. c  o  m
        } else {
            //delete the content of the directory one by one.
            for (final ProjectedINode inode : fileTree.getChildren(dir.getId())) {
                if (!inode.isDirectory()) {
                    final String path = fileTree.createAbsolutePath(subtreeRootPath, inode);
                    Future f = multiTransactionDeleteInternal(fsn, path, subTreeRootID);
                    barrier.add(f);
                }
            }
            // the dir is empty now. delete it.
            final String path = fileTree.createAbsolutePath(subtreeRootPath, dir);
            Future f = multiTransactionDeleteInternal(fsn, path, subTreeRootID);
            barrier.add(f);
        }
    }

    boolean result = true;
    for (Future f : barrier) {
        try {
            if (!((Boolean) f.get())) {
                result = false;
            }
        } catch (ExecutionException e) {
            result = false;
            LOG.error("Exception was thrown during partial delete", e);
            Throwable throwable = e.getCause();
            if (throwable instanceof IOException) {
                throw (IOException) throwable; //pass the exception as is to the client
            } else {
                throw new IOException(e); //only io exception as passed to clients.
            }
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    return result;
}

From source file:net.daporkchop.porkbot.command.music.CommandPlay.java

public void execute(MessageReceivedEvent evt, String[] split, String rawContent) {
    if (split.length < 2) {
        sendErrorMessage(evt.getTextChannel(), "Not enough arguments!");
        return;/*from w w  w  . j  a va2s  . c  o  m*/
    }
    if (validator.isValid(split[1])) {
        AudioUtils.loadAndPlay(evt.getTextChannel(), split[1], evt.getMember());
    } else {
        try {
            AudioUtils.loadAndPlay(evt.getTextChannel(), AudioUtils.videoNameCache.get(rawContent.substring(7)),
                    evt.getMember());
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }
}

From source file:FutureTest.java

public Integer call() {
    count = 0;//from   w w  w . j  a v a2 s  .c o m
    try {
        File[] files = directory.listFiles();
        ArrayList<Future<Integer>> results = new ArrayList<Future<Integer>>();

        for (File file : files)
            if (file.isDirectory()) {
                MatchCounter counter = new MatchCounter(file, keyword);
                FutureTask<Integer> task = new FutureTask<Integer>(counter);
                results.add(task);
                Thread t = new Thread(task);
                t.start();
            } else {
                if (search(file))
                    count++;
            }

        for (Future<Integer> result : results)
            try {
                count += result.get();
            } catch (ExecutionException e) {
                e.printStackTrace();
            }
    } catch (InterruptedException e) {
    }
    return count;
}

From source file:ThreadPoolTest.java

public Integer call() {
    count = 0;// www  .  j av a  2  s . c o  m
    try {
        File[] files = directory.listFiles();
        ArrayList<Future<Integer>> results = new ArrayList<Future<Integer>>();

        for (File file : files)
            if (file.isDirectory()) {
                MatchCounter counter = new MatchCounter(file, keyword, pool);
                Future<Integer> result = pool.submit(counter);
                results.add(result);
            } else {
                if (search(file))
                    count++;
            }

        for (Future<Integer> result : results)
            try {
                count += result.get();
            } catch (ExecutionException e) {
                e.printStackTrace();
            }
    } catch (InterruptedException e) {
    }
    return count;
}

From source file:de.spektrakel.sling.contrib.elasticsearch.ElasticsearchResourceProvider.java

@Override
public Resource getResource(ResourceResolver resourceResolver, String path) {
    try {//  w  w  w .  java 2s.co m
        apiStuff();
    } catch (ExecutionException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

    return null;
}

From source file:org.apache.hadoop.hbase.client.TestAsyncRegionLocatorTimeout.java

@Test
public void test() throws InterruptedException, ExecutionException {
    SLEEP_MS = 1000;/*ww  w . j av  a2  s  . c o  m*/
    long startNs = System.nanoTime();
    try {
        LOCATOR.getRegionLocation(TABLE_NAME, EMPTY_START_ROW, RegionLocateType.CURRENT,
                TimeUnit.MILLISECONDS.toNanos(500)).get();
        fail();
    } catch (ExecutionException e) {
        e.printStackTrace();
        assertThat(e.getCause(), instanceOf(TimeoutIOException.class));
    }
    long costMs = TimeUnit.NANOSECONDS.toMillis(System.nanoTime() - startNs);
    assertTrue(costMs >= 500);
    assertTrue(costMs < 1000);
    // wait for the background task finish
    Thread.sleep(2000);
    // Now the location should be in cache, so we will not visit meta again.
    HRegionLocation loc = LOCATOR.getRegionLocation(TABLE_NAME, EMPTY_START_ROW, RegionLocateType.CURRENT,
            TimeUnit.MILLISECONDS.toNanos(500)).get();
    assertEquals(loc.getServerName(), TEST_UTIL.getHBaseCluster().getRegionServer(0).getServerName());
}

From source file:it.uniroma2.foundme.studente.DelAccountActivity.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_del_account);

    etMail = (EditText) findViewById(R.id.etMail);
    etPsw = (EditText) findViewById(R.id.etPsw);
    btConfirm = (Button) findViewById(R.id.btConfirm);

    btConfirm.setOnClickListener(new View.OnClickListener() {
        @Override/*from  w  w w .  j ava2  s  .  c om*/
        public void onClick(View arg0) {
            mail = etMail.getText().toString();
            pass = etPsw.getText().toString();

            if (!checkData(mail, pass)) {
                Toast.makeText(getApplicationContext(), Variables_it.FILL_FIELD, Toast.LENGTH_LONG).show();
            } else {
                pass = computeSHAHash.sha1(pass);
                try {
                    manageCourse(mail, pass);
                } catch (ExecutionException e) {
                    e.printStackTrace();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }
    });

}

From source file:it.uniroma2.foundme.studente.LoginActivity.java

private void GetSharedPref() {
    pref = SPEditor.init(LoginActivity.this.getApplicationContext());
    user = SPEditor.getUser(pref);/*from  w  w w  .  j  a  va2s  .  co  m*/
    pass = SPEditor.getPass(pref);
    if (user == null || user.isEmpty() || pass == null || pass.isEmpty()) {
        return;
    }
    //new Login().execute(user, pass);
    try {
        manageLogin(user, pass);
    } catch (ExecutionException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}