Search in sources :

Example 71 with ExecutionException

use of java.util.concurrent.ExecutionException in project hive by apache.

the class HiveMetaStoreChecker method checkPartitionDirs.

private void checkPartitionDirs(final ExecutorService executor, final Path basePath, final Set<Path> result, final FileSystem fs, final int maxDepth) throws HiveException {
    try {
        Queue<Future<Path>> futures = new LinkedList<Future<Path>>();
        ConcurrentLinkedQueue<PathDepthInfo> nextLevel = new ConcurrentLinkedQueue<>();
        nextLevel.add(new PathDepthInfo(basePath, 0));
        //not done right
        while (!nextLevel.isEmpty()) {
            ConcurrentLinkedQueue<PathDepthInfo> tempQueue = new ConcurrentLinkedQueue<>();
            //process each level in parallel
            while (!nextLevel.isEmpty()) {
                futures.add(executor.submit(new PathDepthInfoCallable(nextLevel.poll(), maxDepth, fs, tempQueue)));
            }
            while (!futures.isEmpty()) {
                Path p = futures.poll().get();
                if (p != null) {
                    result.add(p);
                }
            }
            //update the nextlevel with newly discovered sub-directories from the above
            nextLevel = tempQueue;
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error(e.getMessage());
        executor.shutdownNow();
        throw new HiveException(e.getCause());
    }
}
Also used : Path(org.apache.hadoop.fs.Path) Future(java.util.concurrent.Future) ConcurrentLinkedQueue(java.util.concurrent.ConcurrentLinkedQueue) ExecutionException(java.util.concurrent.ExecutionException) LinkedList(java.util.LinkedList)

Example 72 with ExecutionException

use of java.util.concurrent.ExecutionException in project hive by apache.

the class CodahaleMetrics method getTimer.

// This method is necessary to synchronize lazy-creation to the timers.
private Timer getTimer(String name) {
    String key = name;
    try {
        timersLock.lock();
        Timer timer = timers.get(key);
        return timer;
    } catch (ExecutionException e) {
        throw new IllegalStateException("Error retrieving timer " + name + " from the metric registry ", e);
    } finally {
        timersLock.unlock();
    }
}
Also used : Timer(com.codahale.metrics.Timer) ExecutionException(java.util.concurrent.ExecutionException)

Example 73 with ExecutionException

use of java.util.concurrent.ExecutionException in project storm by apache.

the class DRPCServerTest method testFailedThrift.

@Test
public void testFailedThrift() throws Exception {
    int drpcPort = Utils.getAvailablePort();
    int invocationsPort = Utils.getAvailablePort(drpcPort + 1);
    Map<String, Object> conf = getConf(drpcPort, invocationsPort, null);
    try (DRPCServer server = new DRPCServer(conf)) {
        exec.submit(() -> {
            server.start();
            return null;
        });
        try (DRPCClient client = new DRPCClient(conf, "localhost", drpcPort);
            DRPCInvocationsClient invoke = new DRPCInvocationsClient(conf, "localhost", invocationsPort)) {
            Future<String> found = exec.submit(() -> client.getClient().execute("testing", "test"));
            DRPCRequest request = getNextAvailableRequest(invoke, "testing");
            assertNotNull(request);
            assertEquals("test", request.get_func_args());
            assertNotNull(request.get_request_id());
            invoke.failRequest(request.get_request_id());
            try {
                found.get(1000, TimeUnit.MILLISECONDS);
                fail("exec did not throw an exception");
            } catch (ExecutionException e) {
                Throwable t = e.getCause();
                assertEquals(t.getClass(), DRPCExecutionException.class);
                //Don't know a better way to validate that it failed.
                assertEquals("Request failed", ((DRPCExecutionException) t).get_msg());
            }
        }
    }
}
Also used : DRPCServer(org.apache.storm.daemon.drpc.DRPCServer) DRPCInvocationsClient(org.apache.storm.drpc.DRPCInvocationsClient) DRPCRequest(org.apache.storm.generated.DRPCRequest) DRPCExecutionException(org.apache.storm.generated.DRPCExecutionException) DRPCClient(org.apache.storm.utils.DRPCClient) ExecutionException(java.util.concurrent.ExecutionException) DRPCExecutionException(org.apache.storm.generated.DRPCExecutionException) Test(org.junit.Test)

Example 74 with ExecutionException

use of java.util.concurrent.ExecutionException in project zeppelin by apache.

the class ZeppelinhubClient method connect.

private ZeppelinhubSession connect() {
    ZeppelinhubSession zeppelinSession;
    try {
        ZeppelinhubWebsocket ws = ZeppelinhubWebsocket.newInstance(zeppelinhubToken);
        Future<Session> future = client.connect(ws, zeppelinhubWebsocketUrl, conectionRequest);
        Session session = future.get();
        zeppelinSession = ZeppelinhubSession.createInstance(session, zeppelinhubToken);
    } catch (IOException | InterruptedException | ExecutionException e) {
        LOG.info("Couldnt connect to zeppelinhub - {}", e.toString());
        zeppelinSession = ZeppelinhubSession.EMPTY;
    }
    return zeppelinSession;
}
Also used : ZeppelinhubSession(org.apache.zeppelin.notebook.repo.zeppelinhub.websocket.session.ZeppelinhubSession) IOException(java.io.IOException) ZeppelinhubWebsocket(org.apache.zeppelin.notebook.repo.zeppelinhub.websocket.listener.ZeppelinhubWebsocket) ExecutionException(java.util.concurrent.ExecutionException) Session(org.eclipse.jetty.websocket.api.Session) ZeppelinhubSession(org.apache.zeppelin.notebook.repo.zeppelinhub.websocket.session.ZeppelinhubSession)

Example 75 with ExecutionException

use of java.util.concurrent.ExecutionException in project zookeeper by apache.

the class NodeViewerMetaData method nodeSelectionChanged.

/*
     * (non-Javadoc)
     * 
     * @see
     * org.apache.zookeeper.inspector.gui.nodeviewer.ZooInspectorNodeViewer#
     * nodeSelectionChanged(java.util.Set)
     */
@Override
public void nodeSelectionChanged(List<String> selectedNodes) {
    this.metaDataPanel.removeAll();
    if (selectedNodes.size() > 0) {
        this.selectedNode = selectedNodes.get(0);
        SwingWorker<Map<String, String>, Void> worker = new SwingWorker<Map<String, String>, Void>() {

            @Override
            protected Map<String, String> doInBackground() throws Exception {
                return NodeViewerMetaData.this.zooInspectorManager.getNodeMeta(NodeViewerMetaData.this.selectedNode);
            }

            @Override
            protected void done() {
                Map<String, String> data = null;
                try {
                    data = get();
                } catch (InterruptedException e) {
                    data = new HashMap<String, String>();
                    LoggerFactory.getLogger().error("Error retrieving meta data for node: " + NodeViewerMetaData.this.selectedNode, e);
                } catch (ExecutionException e) {
                    data = new HashMap<String, String>();
                    LoggerFactory.getLogger().error("Error retrieving meta data for node: " + NodeViewerMetaData.this.selectedNode, e);
                }
                NodeViewerMetaData.this.metaDataPanel.setLayout(new GridBagLayout());
                JPanel infoPanel = new JPanel();
                infoPanel.setBackground(Color.WHITE);
                infoPanel.setLayout(new GridBagLayout());
                int i = 0;
                int rowPos = 0;
                for (Map.Entry<String, String> entry : data.entrySet()) {
                    rowPos = 2 * i + 1;
                    JLabel label = new JLabel(entry.getKey());
                    JTextField text = new JTextField(entry.getValue());
                    text.setEditable(false);
                    GridBagConstraints c1 = new GridBagConstraints();
                    c1.gridx = 0;
                    c1.gridy = rowPos;
                    c1.gridwidth = 1;
                    c1.gridheight = 1;
                    c1.weightx = 0;
                    c1.weighty = 0;
                    c1.anchor = GridBagConstraints.WEST;
                    c1.fill = GridBagConstraints.HORIZONTAL;
                    c1.insets = new Insets(5, 5, 5, 5);
                    c1.ipadx = 0;
                    c1.ipady = 0;
                    infoPanel.add(label, c1);
                    GridBagConstraints c2 = new GridBagConstraints();
                    c2.gridx = 2;
                    c2.gridy = rowPos;
                    c2.gridwidth = 1;
                    c2.gridheight = 1;
                    c2.weightx = 0;
                    c2.weighty = 0;
                    c2.anchor = GridBagConstraints.WEST;
                    c2.fill = GridBagConstraints.HORIZONTAL;
                    c2.insets = new Insets(5, 5, 5, 5);
                    c2.ipadx = 0;
                    c2.ipady = 0;
                    infoPanel.add(text, c2);
                    i++;
                }
                GridBagConstraints c = new GridBagConstraints();
                c.gridx = 1;
                c.gridy = rowPos;
                c.gridwidth = 1;
                c.gridheight = 1;
                c.weightx = 1;
                c.weighty = 1;
                c.anchor = GridBagConstraints.NORTHWEST;
                c.fill = GridBagConstraints.NONE;
                c.insets = new Insets(5, 5, 5, 5);
                c.ipadx = 0;
                c.ipady = 0;
                NodeViewerMetaData.this.metaDataPanel.add(infoPanel, c);
                NodeViewerMetaData.this.metaDataPanel.revalidate();
                NodeViewerMetaData.this.metaDataPanel.repaint();
            }
        };
        worker.execute();
    }
}
Also used : JPanel(javax.swing.JPanel) GridBagConstraints(java.awt.GridBagConstraints) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) HashMap(java.util.HashMap) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) SwingWorker(javax.swing.SwingWorker) ExecutionException(java.util.concurrent.ExecutionException) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

ExecutionException (java.util.concurrent.ExecutionException)1341 IOException (java.io.IOException)367 Test (org.junit.Test)335 TimeoutException (java.util.concurrent.TimeoutException)258 ArrayList (java.util.ArrayList)237 Future (java.util.concurrent.Future)218 ExecutorService (java.util.concurrent.ExecutorService)152 CountDownLatch (java.util.concurrent.CountDownLatch)103 List (java.util.List)98 CancellationException (java.util.concurrent.CancellationException)98 Callable (java.util.concurrent.Callable)97 Test (org.testng.annotations.Test)78 HashMap (java.util.HashMap)69 Map (java.util.Map)65 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)64 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)63 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)56 ParallelTest (com.hazelcast.test.annotation.ParallelTest)47 QuickTest (com.hazelcast.test.annotation.QuickTest)47 UncheckedExecutionException (com.google.common.util.concurrent.UncheckedExecutionException)46