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:com.flipkart.bifrost.CommunicationTest.java

@Test
public void testSendReceive() throws Exception {
    ObjectMapper mapper = new ObjectMapper();
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);

    Connection connection = new Connection(Lists.newArrayList("localhost"), "guest", "guest");
    connection.start();//from   w  ww  .  j a v a2s .c  o  m

    BifrostExecutor<Void> executor = BifrostExecutor.<Void>builder(TestAction.class).connection(connection)
            .objectMapper(mapper).requestQueue("bifrost-send").responseQueue("bifrost-recv").concurrency(10)
            .executorService(Executors.newFixedThreadPool(10)).build();

    BifrostRemoteCallExecutionServer<Void> executionServer = BifrostRemoteCallExecutionServer
            .<Void>builder(TestAction.class).objectMapper(mapper).connection(connection).concurrency(10)
            .requestQueue("bifrost-send").build();
    executionServer.start();

    long startTime = System.currentTimeMillis();
    AtomicInteger counter = new AtomicInteger(0);
    int requestCount = 100;
    CompletionService<Void> ecs = new ExecutorCompletionService<>(Executors.newFixedThreadPool(50));
    List<Future<Void>> futures = Lists.newArrayListWithCapacity(requestCount);
    for (int i = 0; i < requestCount; i++) {
        futures.add(ecs.submit(new ServiceCaller(executor, counter)));
    }
    for (int i = 0; i < requestCount; i++) {
        try {
            ecs.take().get();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }
    System.out.println(
            String.format("Completed: %d in %d ms", counter.get(), (System.currentTimeMillis() - startTime)));
    executor.shutdown();
    executionServer.stop();
    connection.stop();

    Assert.assertEquals(requestCount, counter.get());
}

From source file:com.flipkart.bifrost.ListenTest.java

@Test
public void testSendReceive() throws Exception {
    ObjectMapper mapper = new ObjectMapper();
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY);

    Connection connection = new Connection(Lists.newArrayList("localhost"), "guest", "guest");
    connection.start();/*from   w w  w  . j a  v  a2  s .c  o m*/

    BifrostExecutor<Void> executor = BifrostExecutor.<Void>builder(TestAction.class).connection(connection)
            .objectMapper(mapper).requestQueue("bifrost-send").responseQueue("bifrost-recv").concurrency(20)
            .executorService(Executors.newFixedThreadPool(20)).build();

    BifrostRemoteCallExecutionServer<Void> executionServer = BifrostRemoteCallExecutionServer
            .<Void>builder(TestAction.class).objectMapper(mapper).connection(connection).concurrency(20)
            .requestQueue("bifrost-send").build();
    executionServer.start();

    long startTime = System.currentTimeMillis();
    AtomicInteger counter = new AtomicInteger(0);
    int requestCount = 1000000;
    CompletionService<Void> ecs = new ExecutorCompletionService<>(Executors.newFixedThreadPool(50));
    List<Future<Void>> futures = Lists.newArrayListWithCapacity(requestCount);
    for (int i = 0; i < requestCount; i++) {
        futures.add(ecs.submit(new ServiceCaller(executor, counter)));
    }
    for (int i = 0; i < requestCount; i++) {
        try {
            ecs.take().get();
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }
    while (counter.get() != requestCount)
        ;
    System.out.println(
            String.format("Completed: %d in %d ms", counter.get(), (System.currentTimeMillis() - startTime)));
    executor.shutdown();
    executionServer.stop();
    connection.stop();

    Assert.assertEquals(requestCount, counter.get());
}

From source file:org.openbaton.nfvo.vnfm_reg.impl.receiver.VnfmReceiverRest.java

@RequestMapping(value = "vnfm-core-allocate", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.ACCEPTED)//from  w ww. j a  v  a2  s  .  c  o m
public NFVMessage allocate(@RequestBody VnfmOrAllocateResourcesMessage message) throws VimException {

    try {
        return mapper.fromJson(vnfmManager.executeAction(message), OrVnfmGenericMessage.class);
    } catch (ExecutionException e1) {
        e1.printStackTrace();
    } catch (InterruptedException e1) {
        e1.printStackTrace();
    }
    return null;
}

From source file:org.codehaus.httpcache4j.cache.ConcurrentCacheStorageAbstractTest.java

protected void testIterations(int numberOfIterations, int expected) throws InterruptedException {
    List<Callable<HTTPResponse>> calls = new ArrayList<Callable<HTTPResponse>>();
    for (int i = 0; i < numberOfIterations; i++) {
        final URI uri = URI.create(String.valueOf(i));
        final HTTPRequest request = new HTTPRequest(uri);
        Callable<HTTPResponse> call = new Callable<HTTPResponse>() {
            public HTTPResponse call() throws Exception {
                HTTPResponse cached = cacheStorage.insert(request, createCacheResponse());
                assertResponse(cached);/*from   w ww .  j a va2s.  c o  m*/
                CacheItem cacheItem = cacheStorage.get(request);
                HTTPResponse response = cacheItem.getResponse();
                assertResponse(response);
                cached = cacheStorage.update(request, createCacheResponse());
                assertNotSame(cached, cacheItem.getResponse());
                assertResponse(cached);
                return cached;
            }
        };
        calls.add(call);
    }
    List<Future<HTTPResponse>> responses = service.invokeAll(calls);
    for (Future<HTTPResponse> responseFuture : responses) {
        try {
            responseFuture.get();
        } catch (ExecutionException e) {
            e.printStackTrace();
            fail(e.getCause().getMessage());
        }
    }
    assertEquals(expected, cacheStorage.size());
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    GetSharedPref();//from  w w w .  j  av a2  s .c  o m

    setContentView(R.layout.activity_login);

    btAccess = (Button) findViewById(R.id.btAccess);
    etUser = (EditText) findViewById(R.id.etUserName);
    etPpass = (EditText) findViewById(R.id.etPassword);
    tvRegistration = (TextView) findViewById(R.id.tvRegistration);

    tvRegistration.setOnClickListener(new View.OnClickListener() {
        public void onClick(View arg0) {
            Intent goToRegistration = new Intent(LoginActivity.this, RegistrationActivity.class);
            startActivity(goToRegistration);
        }
    });

    btAccess.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View arg0) {
            user = etUser.getText().toString();
            pass = etPpass.getText().toString();
            pass = computeSHAHash.sha1(pass);
            //new Login().execute(user, pass);
            try {
                manageLogin(user, pass);
            } catch (ExecutionException e) {
                e.printStackTrace();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
    });

}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_read_message);
    context = this;

    Bundle passed = getIntent().getExtras();
    Title = passed.getString(Variables_it.COURSE);
    Sid = passed.getString(Variables_it.ID);

    swipeMsg = (SwipeRefreshLayout) findViewById(R.id.swipe_msg);
    swipeMsg.setEnabled(false);//  w w w. j  ava2  s. c o m
    lvMessaggi = (ListView) findViewById(R.id.lvmes);

    try {
        getMsg(Title, true);
    } catch (ExecutionException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_show_courses);
    context = this;
    swipeShow = (SwipeRefreshLayout) findViewById(R.id.swipe_show);
    swipeShow.setEnabled(false);/*from w  w  w.  j  av a2s  . c  om*/

    lvCorsiSeguiti = (ListView) findViewById(R.id.lvCorsiSeguiti);

    Bundle passed = getIntent().getExtras();
    Sid = passed.getString(Variables_it.ID);

    try {
        getCourse(true);
    } catch (ExecutionException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}

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

@Test
public void testOperationTimeout() throws IOException, InterruptedException {
    long startNs = System.nanoTime();
    try {/*  w w  w .j  a  va2s  . com*/
        CONN.callerFactory.single().table(TABLE_NAME).row(ROW).operationTimeout(1, TimeUnit.SECONDS)
                .pause(100, TimeUnit.MILLISECONDS).maxAttempts(Integer.MAX_VALUE)
                .action((controller, loc, stub) -> failedFuture()).call().get();
        fail();
    } catch (ExecutionException e) {
        e.printStackTrace();
        assertThat(e.getCause(), instanceOf(RetriesExhaustedException.class));
    }
    long costNs = System.nanoTime() - startNs;
    assertTrue(costNs >= TimeUnit.SECONDS.toNanos(1));
    assertTrue(costNs < TimeUnit.SECONDS.toNanos(2));
}

From source file:org.hspconsortium.platform.authorization.repository.impl.LdapUserInfoRepository.java

@Override
public UserInfo getByUsername(String username) {
    try {//from ww w.  j av a 2  s . c om
        return cache.get(username);
    } catch (UncheckedExecutionException ue) {
        return null;
    } catch (ExecutionException e) {
        e.printStackTrace();
        return null;
    }
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_course);

    context = this;

    course = (TextView) findViewById(R.id.tvNameCoures);
    prof = (TextView) findViewById(R.id.tvNameProf);
    ass1 = (TextView) findViewById(R.id.tvNameAss1);
    ass2 = (TextView) findViewById(R.id.tvNameAss2);
    msg = (Button) findViewById(R.id.btnMsg);

    notifica = (Switch) findViewById(R.id.switch_notif);

    imgUniroma2 = (ImageButton) findViewById(R.id.imageButton);

    Bundle passed = getIntent().getExtras();
    Data = passed.getString(Variables_it.COURSE);
    extractData(Data);/*from   w w  w .  ja v a 2 s  . co  m*/

    pref = SPEditor.init(CourseActivity.this.getApplicationContext());
    Sid = SPEditor.getID(pref);

    try {
        manageInfo(Title, Prof, Sid);
    } catch (ExecutionException e) {
        e.printStackTrace();
    } catch (InterruptedException e) {
        e.printStackTrace();
    }

    imgUniroma2.setOnClickListener(new View.OnClickListener() {
        public void onClick(View arg0) {
            Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(Variables_it.SITE_TV));
            startActivity(browserIntent);
        }
    });

    msg.setOnClickListener(new View.OnClickListener() {
        public void onClick(View arg0) {
            Intent i = new Intent(CourseActivity.this, ReadMessageActivity.class);
            i.putExtra(Variables_it.COURSE, Title);
            i.putExtra(Variables_it.ID, Sid);
            startActivity(i);
        }
    });
}