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:org.aliuge.crawler.store.es.EsClient.java

/**
 * mapping/*from   w w  w .  jav  a2 s. c o  m*/
 */
public void putMapping() {
    try {
        client.admin().indices().preparePutMapping("movie").setType("0").setSource(mapping).execute().get();
    } catch (InterruptedException e) {
        e.printStackTrace();
    } catch (ExecutionException f) {
        f.printStackTrace();
    }
}

From source file:org.aliuge.crawler.store.es.EsClient.java

/**
 * mapping//from ww  w  .j a  va  2s .  c  o  m
 * 
 * @param index
 * @param type
 * @param file
 */
public void putMappingFile(String index, String type, File file) {
    try {
        String m = FileUtils.readFileToString(file, "utf-8");
        client.admin().indices().preparePutMapping("moive").setType("0").setSource(m).execute().get();
    } catch (IOException e) {
        e.printStackTrace();
    } catch (InterruptedException f) {
        f.printStackTrace();
    } catch (ExecutionException g) {
        g.printStackTrace();
    }
}

From source file:sebastian.hohns.imagezoom.converter.JImagePyramideProcessor.java

/**
 * Cut tiles from a row of a level./*from   www  . j  a  v  a 2s  . com*/
 * @param p original image
 * @param row row of a level of the image pyramide.
 * @param rowDone determines if the row is fully calculated.
 */
public void buildTiles(OriginalImage p, ImageRow row, Future rowDone) {
    //Check and wait till the ImageRow is ready
    if (rowDone != null) {
        try {
            rowDone.get();
        } catch (InterruptedException ie) {
            ie.printStackTrace();
        } catch (ExecutionException ee) {
            ee.printStackTrace();
        }
    }

    //Cut tiles from row.
    for (int i = 0; i <= row.getRequiredCols(); i++) {
        service.submit(new ImageTile(this, row, p.getTargetDir() + File.separator
                + format.getTileGroup(p.getTargetDir(), p.incrementTileCounter()), i));
    }
}

From source file:sebastian.hohns.imagezoom.converter.JImagePyramideProcessor.java

/**
 * Cut rows form a level of the pyramide.
 * @param p original image//  ww  w.j a  v  a  2s .  c  o m
 * @param level level of the image pyramide.
 * @param levelDone determines if the level is fully calculated.
 */
public void buildRows(OriginalImage p, ImageLevel level, Future levelDone) {
    //Check and wait till the ImageLevel is ready
    if (levelDone != null) {
        try {
            levelDone.get();
        } catch (InterruptedException ie) {
            ie.printStackTrace();
        } catch (ExecutionException ee) {
            ee.printStackTrace();
        }
    }

    //Build the required rows
    ImageRow row;
    for (int i = 0; i <= level.getRequiredRows(); i++) {
        row = new ImageRow(this, p, level, level.getWidth(), format.getTileHeight(), i);
        Future f = service.submit(row);
        buildTiles(p, row, f);
    }
}

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

@Override
protected void onPostExecute(String result[]) {
    if (result[0].equalsIgnoreCase(Variables_it.NO_INTERNET)) {
        if (enProgressDialog)
            caricamento.dismiss();/*from w w  w  .  j  a va 2  s.  c om*/
        Toast.makeText(context, result[0], Toast.LENGTH_SHORT).show();
        return;
    }
    if (enProgressDialog) {
        caricamento.dismiss();
        if (!returnMessage.equalsIgnoreCase(Variables_it.NAME)
                || result[0].equalsIgnoreCase(Variables_it.ERROR)) {
            if (!returnMessage.equalsIgnoreCase("") && !returnMessage.equalsIgnoreCase(Variables_it.NO_MSG)) {
                Toast.makeText(context, result[0], Toast.LENGTH_SHORT).show();
            }
        }
    }
    if (returnMessage.equalsIgnoreCase(Variables_it.NO_MSG)) {
        ReadMessageActivity.populateView(result);
    } else if (returnMessage.equalsIgnoreCase(Variables_it.DEL_MSG_OK)) {
        try {
            ReadMessageActivity.getMsg(toDo, false);
        } catch (ExecutionException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    } else if (toDo.equalsIgnoreCase(Variables_it.GET)) {
        HomeActivity.populateView(result);
    } else if (returnMessage.equalsIgnoreCase(Variables_it.SEND_MSG_OK)
            && toDo.equalsIgnoreCase(Variables_it.MSGS)) {
        ((Activity) context).finish();
    } else if (returnMessage.equalsIgnoreCase(Variables_it.NAME) && toDo.equalsIgnoreCase(Variables_it.LOG)
            && !result[0].equalsIgnoreCase(Variables_it.ERROR)) {
        SharedPreferences pref = SPEditor.init(context);
        SPEditor.setUser(pref, LoginActivity.getuser());
        SPEditor.setPass(pref, LoginActivity.getpass());
        Intent intent = new Intent(context, HomeActivity.class);
        intent.putExtra(Variables_it.TAG, LoginActivity.gettag());
        intent.putExtra(Variables_it.NAME, result[0]);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
        context.startActivity(intent);
    } else if (code == 1 && toDo.equalsIgnoreCase(Variables_it.FINISH)) {
        ((Activity) context).finish();
        try {
            HomeActivity.getCourse(true);
        } catch (ExecutionException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    } else if (code == 1 && toDo.equalsIgnoreCase(Variables_it.CHANGEP)) {
        SharedPreferences pref = SPEditor.init(context);
        SPEditor.setPass(pref, ChangePswActivity.getpass());
        ((Activity) context).finish();
    } else if (code == 1 && toDo.equalsIgnoreCase(Variables_it.REGIS)) {
        SharedPreferences pref = SPEditor.init(context);
        SPEditor.setUser(pref, RegistrationActivity.getmail());
        SPEditor.setPass(pref, RegistrationActivity.getpass());
        ((Activity) context).finish();
    } else if (code == 1 && toDo.equalsIgnoreCase(Variables_it.DELACC)) {
        SharedPreferences pref = SPEditor.init(context);
        SPEditor.delete(pref);
        Intent intent = new Intent(context, LoginActivity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
        context.startActivity(intent);
    }

    else if (code == 1 && toDo.equalsIgnoreCase(Variables_it.HOME)) {
        try {
            HomeActivity.getCourse(false);
        } catch (ExecutionException e) {
            e.printStackTrace();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

From source file:sebastian.hohns.imagezoom.converter.JImagePyramideProcessor.java

/**
 * Build a level of the image pyramide.//from w  w  w.  j  a  va 2s  .c o  m
 * @param p object representing the original image
 * @param orgPrepared determines if original image is prepared
 */
public void buildZoomlevel(OriginalImage p, Future orgPrepared) {
    //Check and wait till the image is prepared
    if (orgPrepared != null) {
        try {
            orgPrepared.get();
        } catch (InterruptedException ie) {
            ie.printStackTrace();
        } catch (ExecutionException ee) {
            ee.printStackTrace();
        }
    }

    ImageLevel level;

    //Create all required image levels from the top
    for (int i = p.getRequiredlevels(); i >= 1; i--) {
        level = new ImageLevel(this, p, (p.getRequiredlevels() - i),
                format.scaleDimension(p.getImageWidth(), i), format.scaleDimension(p.getImageHeight(), i),
                p.getImagePath());
        Future f = service.submit(level);

        //Build Rows for all but the last image level
        if (i != p.getRequiredlevels()) {
            buildRows(p, level, f);
        }
    }

    //Build rows for the original image
    buildRows(p, new ImageLevel(this, p, (p.getRequiredlevels()), format.scaleDimension(p.getImageWidth(), 0),
            format.scaleDimension(p.getImageHeight(), 0), p.getImagePath()), null);
}

From source file:io.scigraph.owlapi.loader.BatchOwlLoader.java

public void loadOntology() throws InterruptedException, ExecutionException {
    CompletionService<Long> completionService = new ExecutorCompletionService<Long>(exec);
    Set<Future<?>> futures = new HashSet<>();
    if (!ontologies.isEmpty()) {
        for (int i = 0; i < numConsumers; i++) {
            futures.add(completionService.submit(consumerProvider.get()));
        }//from  ww w . ja  v  a 2s .c om
        for (int i = 0; i < numProducers; i++) {
            futures.add(completionService.submit(producerProvider.get()));
        }
        for (OntologySetup ontology : ontologies) {
            urlQueue.offer(ontology);
        }
        for (int i = 0; i < numProducers; i++) {
            urlQueue.offer(POISON_STR);
        }
    }

    while (futures.size() > 0) {
        Future<?> completedFuture = completionService.take();
        futures.remove(completedFuture);
        try {
            completedFuture.get();
        } catch (ExecutionException e) {
            logger.log(Level.SEVERE, "Stopping batchLoading due to: " + e.getMessage(), e);
            e.printStackTrace();
            exec.shutdownNow();
            throw new InterruptedException(e.getCause().getMessage());
        }
    }

    exec.shutdown();
    exec.awaitTermination(10, TimeUnit.DAYS);
    graph.shutdown();
    logger.info("Postprocessing...");
    postprocessorProvider.get().postprocess();

    if (cliqueConfiguration.isPresent()) {
        postprocessorProvider.runCliquePostprocessor(cliqueConfiguration.get());
    }

    postprocessorProvider.shutdown();

}

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

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_registration);
    context = this;
    btSignUp = (Button) findViewById(R.id.btSignUp);

    etNewUser = (EditText) findViewById(R.id.etNewUser);
    etNewPass1 = (EditText) findViewById(R.id.etNewPass);
    etNewPass2 = (EditText) findViewById(R.id.etNewPass2);
    etNewMail = (EditText) findViewById(R.id.etNewMail);
    etNewMail2 = (EditText) findViewById(R.id.etNewMail2);
    etNewId = (EditText) findViewById(R.id.etNewId);
    spDept = (Spinner) findViewById(R.id.spDept);

    final ArrayAdapter<CharSequence> adapter = createFromResource(this, R.array.Departments,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spDept.setAdapter(adapter);/*w w w  .ja va  2  s. c  om*/

    spDept.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        protected Adapter initializedAdapter = null;

        @Override
        public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
            if (initializedAdapter != parentView.getAdapter()) {
                initializedAdapter = parentView.getAdapter();
                return;
            }

            Dept = parentView.getItemAtPosition(position).toString();

        }

        @Override
        public void onNothingSelected(AdapterView<?> parentView) {
            //
        }
    });

    btSignUp.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View arg0) {
            NewUser = etNewUser.getText().toString();
            NewPass1 = etNewPass1.getText().toString();
            NewPass2 = etNewPass2.getText().toString();
            NewMail = etNewMail.getText().toString();
            NewMail2 = etNewMail2.getText().toString();
            NewId = etNewId.getText().toString();

            if (checkPlayServices()) {
                gcm = GoogleCloudMessaging.getInstance(getApplicationContext());
                if (!checkLoginData(NewPass1, NewPass2, NewMail, NewMail2, Dept)) {
                    Toast.makeText(getApplicationContext(), Variables_it.FILL_FIELD, Toast.LENGTH_LONG).show();
                } else {
                    try {
                        manageRegistration(NewUser, NewPass1, NewMail, NewId, Dept);
                    } catch (ExecutionException e) {
                        e.printStackTrace();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    });

}

From source file:blusunrize.immersiveengineering.client.models.smart.ConnModelReal.java

@Nonnull
@Override//from ww w. ja v a  2s.c om
public List<BakedQuad> getQuads(@Nullable IBlockState state, @Nullable EnumFacing side, long rand) {
    if (side == null && state instanceof IExtendedBlockState) {
        IExtendedBlockState ext = (IExtendedBlockState) state;
        Object[] additional = null;
        if (ext.getUnlistedProperties().containsKey(IEProperties.TILEENTITY_PASSTHROUGH)) {
            TileEntity te = ext.getValue(IEProperties.TILEENTITY_PASSTHROUGH);
            if (te instanceof IEBlockInterfaces.ICacheData)
                additional = ((IEBlockInterfaces.ICacheData) te).getCacheData();
        }
        int x = 0, z = 0;
        if (ext.getUnlistedProperties().containsKey(IEProperties.CONNECTIONS)) {
            Set<Connection> conns = ext.getValue(IEProperties.CONNECTIONS);
            if (conns != null && conns.size() > 0) {
                BlockPos tmp = conns.iterator().next().start;
                x = (tmp.getX() % 16 + 16) % 16;
                z = (tmp.getZ() % 16 + 16) % 16;
            }
        }
        ExtBlockstateAdapter ad = new ExtBlockstateAdapter(ext, null, ExtBlockstateAdapter.ONLY_OBJ_CALLBACK,
                additional);
        Pair<Byte, ExtBlockstateAdapter> key = new ImmutablePair<>((byte) ((x << 4) | z), ad);
        try {
            IBakedModel ret = cache.get(key,
                    () -> new AssembledBakedModel(ext, textureAtlasSprite, base, layers));
            return ret.getQuads(state, null, rand);
        } catch (ExecutionException e) {
            e.printStackTrace();
        }
    }
    return getBaseQuads(MinecraftForgeClient.getRenderLayer(), state, side, rand);
}

From source file:edu.umass.cs.gnsserver.activecode.ActiveCodeHandler.java

/**
 * Runs the active code. Returns a {@link ValuesMap}.
 *
 * @param code64 base64 encoded active code, as stored in the db
 * @param guid the guid/*from   ww w. jav a 2 s . c  o  m*/
 * @param field the field
 * @param action either 'read' or 'write'
 * @param valuesMap
 * @param activeCodeTTL the remaining active code TTL
 * @return a Valuesmap
 */
public ValuesMap runCode(String code64, String guid, String field, String action, ValuesMap valuesMap,
        int activeCodeTTL) {
    String code = new String(Base64.decodeBase64(code64));
    String values = valuesMap.toString();
    ValuesMap result = null;

    ActiveCodeParams acp = new ActiveCodeParams(guid, field, action, code, values, activeCodeTTL);
    FutureTask<ValuesMap> futureTask = new FutureTask<>(new ActiveCodeTask(acp, clientPool));

    // If the guid is blacklisted, just return immediately
    if (isBlacklisted(guid)) {
        System.out.println("Guid " + guid + " is blacklisted from running code!");
        return valuesMap;
    }

    // Only run if there are free workers and queue space
    // This prevents excessive CPU usage
    if (executorPool.getPoolSize() > 0 && executorPool.getQueue().remainingCapacity() > 0) {
        executorPool.execute(futureTask);

        try {
            result = futureTask.get();
        } catch (ExecutionException e) {
            System.out.println("Added " + guid + " to blacklist!");
            addToBlacklist(guid);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    } else {
        System.out.println("Rejecting task!");
    }

    return result;
}