Package edu.brown.utils

Examples of edu.brown.utils.EventObservableExceptionHandler


    private ConcurrentLinkedQueue<Integer> availableWarehouseIds = new ConcurrentLinkedQueue<Integer>();

    @Override
    public void load() throws IOException {
        final EventObservableExceptionHandler handler = new EventObservableExceptionHandler();
        handler.addObserver(new EventObserver<Pair<Thread,Throwable>>() {
            public void update(edu.brown.utils.EventObservable<Pair<Thread,Throwable>> o, Pair<Thread,Throwable> t) {
                synchronized (TPCCLoader.this) {
                    if (TPCCLoader.this.pendingError != null) {
                        return;
                    }
View Full Code Here


                genSpeAndCal(catalog_spe, catalog_cal);
                if (d) LOG.debug("Finished loading " + TM1Constants.TABLENAME_SPECIAL_FACILITY + " and " + TM1Constants.TABLENAME_CALL_FORWARDING);
            }
        } };

        final EventObservableExceptionHandler handler = new EventObservableExceptionHandler();
        handler.addObserver(new EventObserver<Pair<Thread,Throwable>>() {
            @Override
            public void update(EventObservable<Pair<Thread, Throwable>> o, Pair<Thread, Throwable> t) {
                for (Thread thread : threads)
                    thread.interrupt();
            }
        });
       
        try {
            for (Thread t : threads) {
                t.setUncaughtExceptionHandler(handler);
                t.start();
                if (this.blocking)
                    t.join();
            } // FOR
            if (!this.blocking) {
                for (Thread t : threads)
                    t.join();
            }
            this.getClientHandle().drain();
        } catch (Exception e) {
            throw new RuntimeException(e);
        } finally {
            if (handler.hasError()) {
                throw new RuntimeException("Error while generating table data.", handler.getError());
            }
        }

//        System.err.println("\n" + this.dumpTableCounts());
    }
View Full Code Here

    /**
     * Call by the benchmark framework to load the table data
     */
    @Override
    public void runLoop() {
        final EventObservableExceptionHandler handler = new EventObservableExceptionHandler();
        final List<Thread> threads = new ArrayList<Thread>();
        for (AbstractTableGenerator generator : this.generators.values()) {
            // if (isSubGenerator(generator)) continue;
            Thread t = new Thread(generator);
            t.setUncaughtExceptionHandler(handler);
            threads.add(t);
            // Make sure we call init first before starting any thread
            generator.init();
        } // FOR
        assert(threads.size() > 0);
        handler.addObserver(new EventObserver<Pair<Thread,Throwable>>() {
            @Override
            public void update(EventObservable<Pair<Thread, Throwable>> o, Pair<Thread, Throwable> t) {
                for (Thread thread : threads)
                    thread.interrupt();
            }
        });
       
        // Construct a new thread to load each table
        // Fire off the threads and wait for them to complete
        // If debug is set to true, then we'll execute them serially
        try {
            for (Thread t : threads) {
                t.start();
            } // FOR
            for (Thread t : threads) {
                t.join();
            } // FOR
        } catch (InterruptedException e) {
            LOG.fatal("Unexpected error", e);
        } finally {
            if (handler.hasError()) {
                throw new RuntimeException("Error while generating table data.", handler.getError());
            }
        }
       
        profile.saveProfile(this);
        LOG.info("Finished generating data for all tables");
View Full Code Here

TOP

Related Classes of edu.brown.utils.EventObservableExceptionHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.