Package org.apache.marmotta.platform.core.api.task

Examples of org.apache.marmotta.platform.core.api.task.Task


    @Override
    public void endTask(TaskInfo task) {
        final Stack<TaskImpl> stack = getStack();
        if (stack.contains(task)) {
            while (!stack.isEmpty()) {
                Task t = stack.pop();
                if (t.equals(task)) {
                    log.debug("Ending task {}.{}", t.getGroup(), t.getName());
                    break;
                } else {
                    log.debug("Ending task {}.{} because it's a sub-task", t.getGroup(), t.getName());
                    t.endTask();
                }
            }
            if (!stack.isEmpty()) {
                stack.peek().subTaskEnded();
            }
View Full Code Here


     * @see xx.test.taks.TaskManagerService#createTask(java.lang.String)
     */
    @Override
    public Task createTask(String name, String group) {
        final Stack<TaskImpl> stack = getStack();
        final Task task;
        if (stack.isEmpty())
            return createSubTask(name, group);
        else {
            task = stack.peek();
            task.updateName(name);
            if (group != null) {
                task.updateGroup(group);
            }
        }
        return task;
    }
View Full Code Here

        @Override
        public void run() {
            running = true;
            log.trace("Watchdog: starting up");
            final Task task = getTask();
            int count = 0;
            while (running) {
                task.updateMessage("cleaning up");
                task.updateProgress(++count);
                try {
                    HashSet<Thread> dead = new HashSet<Thread>();
                    for (Thread t : tasks.keySet()) {
                        if (!t.isAlive()) {
                            dead.add(t);
                        }
                    }
                    for (Thread t : dead) {
                        log.debug("Watchdog: cleaning up dead thread " + t.getName());
                        tasks.remove(t);
                        t = null;
                    }
                    dead.clear();
                    dead = null;
                    task.updateMessage("sleeping");
                    synchronized (ThreadWatchdog.this) {
                        this.wait(millis);
                    }
                } catch (InterruptedException e) {
                    // ignore
                }
            }
            task.endTask();
            log.trace("Watchdog: shutdown");
        }
View Full Code Here

            return delegate.getConnectionManager();
        }

        @Override
        public HttpResponse execute(HttpUriRequest request) throws IOException, ClientProtocolException {
            final Task task = preProcess(request);

            final HttpResponse response;
            lock.readLock().lock();
            try {
                response = delegate.execute(request);
            } catch (ClientProtocolException cpe) {
                task.endTask();
                throw cpe;
            } catch (IOException io) {
                task.endTask();
                throw io;
            } finally {
                lock.readLock().unlock();
            }
View Full Code Here

            return postProcess(response, null, task);
        }

        @Override
        public HttpResponse execute(HttpUriRequest request, HttpContext context) throws IOException, ClientProtocolException {
            final Task task = preProcess(request);

            final HttpResponse response;
            lock.readLock().lock();
            try {
                response = delegate.execute(request, context);
            } catch (ClientProtocolException cpe) {
                task.endTask();
                throw cpe;
            } catch (IOException io) {
                task.endTask();
                throw io;
            } finally {
                lock.readLock().unlock();
            }
View Full Code Here

        private Task preProcess(HttpRequest request) {
            final RequestLine rl = request.getRequestLine();
            final String taskName = String.format("%S %s %S", rl.getMethod(), rl.getUri(), request.getProtocolVersion());

            final Task task = taskManagerService.createSubTask(taskName, TASK_GROUP_CLIENT);
            task.updateMessage("preparing request");
            task.updateDetailMessage("method", rl.getMethod());
            task.updateDetailMessage("url", rl.getUri());
            // TODO: some more detail messages?

            if (request instanceof HttpEntityEnclosingRequest) {
                // To report upload progress, the entity is wrapped in a MonitoredHttpEntity.
                final HttpEntityEnclosingRequest entityRequest = (HttpEntityEnclosingRequest) request;
                entityRequest.setEntity(new MonitoredHttpEntity(entityRequest.getEntity(), task, bytesSent));
            }

            task.updateMessage("sending request");
            return task;
        }
View Full Code Here

            return response;
        }

        @Override
        public HttpResponse execute(HttpHost target, HttpRequest request) throws IOException, ClientProtocolException {
            final Task task = preProcess(request);

            final HttpResponse response;
            lock.readLock().lock();
            try {
                response = delegate.execute(target, request);
            } catch (ClientProtocolException cpe) {
                task.endTask();
                throw cpe;
            } catch (IOException io) {
                task.endTask();
                throw io;
            } finally {
                lock.readLock().unlock();
            }
View Full Code Here

            return postProcess(response, null, task);
        }

        @Override
        public HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context) throws IOException, ClientProtocolException {
            final Task task = preProcess(request);

            final HttpResponse response;
            lock.readLock().lock();
            try {
                response = delegate.execute(target, request, context);
            } catch (ClientProtocolException cpe) {
                task.endTask();
                throw cpe;
            } catch (IOException io) {
                task.endTask();
                throw io;
            } finally {
                lock.readLock().unlock();
            }
View Full Code Here

        // TODO: need to figure out format automatically!
        RDFFormat f = getFormat(format);

        final String taskName = String.format("RDF Importer Task %d (%s)", ++taskCounter, f.getName());
        Task task = taskManagerService.createSubTask(taskName,"Importer");
        task.updateMessage("importing data into Apache Marmotta repository");
        task.updateDetailMessage("format", f.getDefaultMIMEType());
        task.updateDetailMessage("baseUri", baseUri);

        int count = 0;

        try {
            if (is != null) {
View Full Code Here

        // TODO: need to figure out format automatically!
        RDFFormat f = getFormat(format);

        String baseUri = configurationService.getBaseUri() + "resource/";
        final String taskName = String.format("RDF Importer Task %d (%s)", ++taskCounter, f.getName());
        Task task = taskManagerService.createSubTask(taskName, "Importer");
        task.updateMessage("importing data into Apache Marmotta repository");
        task.updateDetailMessage("format", f.getDefaultMIMEType());
        task.updateDetailMessage("baseURI", baseUri);

        int count = 0;

        try {
            if (reader != null) {
View Full Code Here

TOP

Related Classes of org.apache.marmotta.platform.core.api.task.Task

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.