Examples of Worker


Examples of net.greghaines.jesque.worker.Worker

        }
    }

    @Test
    public void testPauseAndShutdownCommands() {
        final Worker worker = new WorkerImpl(config, set(testQueue),
                new MapBasedJobFactory(map(entry("TestAction", TestAction.class))));
        final Admin admin = new AdminImpl(config);
        admin.setWorker(worker);

        final Thread workerThread = new Thread(worker);
        workerThread.start();
        final Thread adminThread = new Thread(admin);
        adminThread.start();

        Assert.assertFalse(worker.isPaused());

        try {
            final AdminClient adminClient = new AdminClientImpl(config);
            try {
                adminClient.togglePausedWorkers(true);
                try {
                    Thread.sleep(1000L);
                } catch (InterruptedException ie) {
                }
                Assert.assertTrue(worker.isPaused());

                Assert.assertFalse(worker.isShutdown());
                adminClient.shutdownWorkers(true);
                try {
                    Thread.sleep(1000L);
                } catch (InterruptedException ie) {
                }
                Assert.assertTrue(worker.isShutdown());
            } finally {
                adminClient.end();
            }
        } finally {
            TestUtils.stopWorker(admin, adminThread);
View Full Code Here

Examples of net.laubenberger.bogatyr.view.swing.worker.Worker

          localizer.getTooltip(HelperResource.RES_ACTION_OK), localizer.getMnemonic(HelperResource.RES_ACTION_OK));
    }

    @Override
    public void actionPerformed(final ActionEvent e) {
      final Worker worker = new WorkerAbstract<Void, Void>() {
        @Override
        protected Void doInBackground() throws Exception {
          fireWorkerStart();

          try {

            final CryptoSymmetricAlgo algo = (CryptoSymmetricAlgo) cbCodecs.getSelectedItem();
            final CryptoSymmetric crypto = new CryptoSymmetricImpl(algo);
            final SecretKey key = crypto.generateKey(new String(password.getPassword())
                .getBytes(Constants.ENCODING_DEFAULT));
            crypto.decrypt(scrambler.getModuleData().getFile(KEY_UNSCRAMBLE_INPUT), scrambler.getModuleData()
                .getFile(KEY_UNSCRAMBLE_OUTPUT), key);
            scrambler.getModuleData().addValue(KEY_UNSCRAMBLE_ALGO, algo);
//          } catch (IOException ex) {
//            log.error("Could not unscramble file", ex); //$NON-NLS-1$
//            scrambler.displayMessage(scrambler.getModel().getName(), "Could not unscramble file",
//                MessageType.ERROR);
          } catch (Exception ex) {
            log.error("Could not unscramble file", ex); //$NON-NLS-1$
            scrambler.displayMessage(scrambler.getModel().getName(), localizer.getValue(HelperResource.RES_ERROR_UNSCRAMBLE),
                MessageType.ERROR);
          }
          return null;
        }
      };

      worker.addListener(scrambler);
      scrambler.getCallback().addWorker(
          worker,
          localizer.getValue(HelperResource.RES_ACTION_UNSCRAMBLE),
          scrambler.getModuleData().getFile(KEY_UNSCRAMBLE_INPUT).getName()
              + " -> " + scrambler.getModuleData().getFile(KEY_UNSCRAMBLE_OUTPUT).getName(), Icons.UNSCRAMBLE); //$NON-NLS-1$
View Full Code Here

Examples of net.laubenberger.bogatyr.view.swing.worker.Worker

    enableControls();
  }

  void play(final File file) {

    final Worker worker = new WorkerAbstract<Void, Void>() {
      @Override
      protected Void doInBackground() throws Exception {
        fireWorkerStart();

        BufferedInputStream bis = null;
        try {
          bis = new BufferedInputStream(new FileInputStream(file), FILE_BUFFER_SIZE);

          try {
            player = new AdvancedPlayer(bis);
            player.setPlayBackListener(new PlaybackListener() {
              @Override
              public void playbackStarted(final PlaybackEvent playbackevent) {

                isRunning = true;

                SwingUtilities.invokeLater(new Runnable() {
                  @Override
                  public void run() {
                    commander.setTitle(file.getName());
                    commander.getRootPane().setToolTipText(file.getAbsolutePath());
                    enableControls();
                  }

                });

              }

              @Override
              public void playbackFinished(final PlaybackEvent playbackevent) {
                if (isRunning) {
                  index++;
                  if (index >= list.size()) {
                    index = 0;
                  }

                  player.close();

                  play(list.get(index));
                }
              }
            });

            player.play();

          } catch (JavaLayerException e) {
            log.error("Could not process MP3 file", e); //$NON-NLS-1$
          }
        } catch (FileNotFoundException ex) {
          log.error("File not found", ex); //$NON-NLS-1$
        } finally {
          if (null != bis) {
            try {
              bis.close();
            } catch (IOException ex) {
              log.error("Could not close file", ex); //$NON-NLS-1$
            }
          }
        }

        return null;
      }
    };

    worker.addListener(this);
    worker.execute();
  }
View Full Code Here

Examples of net.laubenberger.bogatyr.view.swing.worker.Worker

          localizer.getTooltip(HelperResource.RES_ACTION_OK), localizer.getMnemonic(HelperResource.RES_ACTION_OK));
    }

    @Override
    public void actionPerformed(final ActionEvent e) {
      final Worker worker = new WorkerAbstract<Void, Void>() {
        @Override
        protected Void doInBackground() throws Exception {
          fireWorkerStart();

          try {
            final CryptoSymmetricAlgo algo = (CryptoSymmetricAlgo) cbCodecs.getSelectedItem();
            final CryptoSymmetric crypto = new CryptoSymmetricImpl(algo);
            final SecretKey key = crypto.generateKey(new String(password1.getPassword())
                .getBytes(Constants.ENCODING_DEFAULT));
            crypto.encrypt(scrambler.getModuleData().getFile(KEY_SCRAMBLE_INPUT), scrambler.getModuleData()
                .getFile(KEY_SCRAMBLE_OUTPUT), key);
            scrambler.getModuleData().addValue(KEY_SCRAMBLE_ALGO, algo);
//          } catch (IOException ex) {
//            log.error("Could not scramble file", ex); //$NON-NLS-1$
//            scrambler
//                .displayMessage(scrambler.getModel().getName(), "Could not scramble file", MessageType.ERROR);
          } catch (Exception ex) {
            log.error("Could not scramble file", ex); //$NON-NLS-1$
            scrambler
                .displayMessage(scrambler.getModel().getName(), localizer.getValue(HelperResource.RES_ERROR_SCRAMBLE), MessageType.ERROR);
          }

          return null;
        }
      };

      worker.addListener(scrambler);
      scrambler.getCallback().addWorker(
          worker,
          localizer.getValue(HelperResource.RES_ACTION_SCRAMBLE),
          scrambler.getModuleData().getFile(KEY_SCRAMBLE_INPUT).getName()
              + " -> " + scrambler.getModuleData().getFile(KEY_SCRAMBLE_OUTPUT).getName(), Icons.SCRAMBLE); //$NON-NLS-1$
View Full Code Here

Examples of net.laubenberger.bogatyr.view.swing.worker.Worker

    }

    @Override
    public void actionPerformed(final ActionEvent e) {

      final Worker worker = new WorkerAbstract<Void, Void>() {
        @Override
        protected Void doInBackground() throws Exception {
          fireWorkerStart();

          while (!isCancelled()) {
            Thread.sleep(250);
          }

          return null;
        }
      };

      worker.addListener(TestImpl.this);
      getCallback().addWorker(worker, localizer.getValue(HelperResource.RES_ACTION_TASK), "working...", Icons.TASK);

      // worker.execute();
      final Thread thread = new Thread(worker);
      thread.start();
View Full Code Here

Examples of net.laubenberger.bogatyr.view.swing.worker.Worker

        actionSkipForward.setEnabled(false);

        final File file = fc.getSelectedFile();

        if (file.isDirectory()) {
          final Worker worker = new WorkerAbstract<Void, Void>() {
            @Override
            protected Void doInBackground() throws Exception {
              fireWorkerStart();

              final FileFilter filter = new FileFilter() {
                @Override
                public boolean accept(final File file) {
                  return HelperString.endsWith(file.getName(), ".mp3"); //$NON-NLS-1$
                }
              };

              if (isRunning) {
                stop();
              }
             
              if (getModuleData().getBoolean(KEY_IS_ENQUEUE)) {
                list.addAll(HelperIO.getFiles(file, filter));
              } else {
                list = HelperIO.getFiles(file, filter);
                index = 0;
              }

              if (getModuleData().getBoolean(KEY_IS_RANDOM)) {
                Collections.shuffle(list);
              } else {
                Collections.sort(list);
              }

              return null;
            }

            @Override
            protected void done() {
              actionOpen.setEnabled(true);
              enableControls();

              super.done();
            }
          };
          worker.addListener(MusicPlayerImpl.this);

          // Thread thread = new Thread(worker);
          // thread.start();
          worker.execute();

          getCallback().addWorker(worker, localizer.getValue(HelperResource.RES_ACTION_START),
              localizer.getValue(HelperResource.RES_LABEL_SCANNING), Icons.START);
        } else {
          if (isRunning) {
View Full Code Here

Examples of net.tomp2p.task.Worker

            Number160 taskId = message.getKey();
            // request 1 is task creation
            Map<Number160, Data> dataMap = message.getDataMap();
            ChannelBuffer channelBuffer = message.getPayload1();
            Object obj = Utils.decodeJavaObject(channelBuffer);
            Worker mapper = (Worker) obj;
            int queuePosition = taskManager.submitTask(getPeerBean().getPeer(), taskId, mapper, dataMap,
                    message.getSender(), sign);
            responseMessage.setInteger(queuePosition);
        } else if (message.getType() == Type.REQUEST_2) {
            Collection<Number160> taskIDs = message.getKeys();
View Full Code Here

Examples of org.apache.hadoop.raid.DistBlockIntegrityMonitor.Worker

    String[] fileNames = {"file0", "file1", "file2", "file3", "file4"};
    long[][] crcs = new long[fileNames.length][];
    FileStatus[] files = new FileStatus[fileNames.length];
   
    createRandomFiles(filePath, fileNames, 2, blocksPerFile, crcs, files);
    Worker bc =
      ((DistBlockIntegrityMonitor) raidnode.blockIntegrityMonitor).getDecommissioningMonitor();
   
    for (FileStatus file : files) {
      printFileLocations(file);
    }
   
   
    Set<String> downNodes = new HashSet<String>();
    for (int i = 0; i < numDatanodes; i++) {
      // Decommission a node and test the data source.
      String downNode = decommissionOneNode();
      downNodes.add(downNode);

      // Compute which files have decommissioning blocks and how many
      HashMap<String, Integer> decomFiles = new HashMap<String, Integer>();
      for (FileStatus file : files) {

        String path = file.getPath().toUri().getPath();
        int decommissioningBlocks = 0;
        BlockLocation[] locations =
          fileSys.getFileBlockLocations(file, 0, file.getLen());

        for (BlockLocation loc : locations) {
          String[] names = loc.getNames();
          if (downNodes.contains(names[0]) && downNodes.contains(names[1])) {
            decommissioningBlocks++;
          }
        }
        if (decommissioningBlocks > 0) {
          decomFiles.put(path, decommissioningBlocks);
        }
      }
     
      // Verify results
      // FIXME: re-enable test when the underlying issue in fsck/namesystem is resolved
      //assertEquals(decomFiles.keySet(), bf.getDecommissioningFiles().keySet()); 
    }
   
    // Un-decommission those nodes and test the data source again.
    writeExcludesFileAndRefresh(null);
    assertEquals(0, bc.getLostFiles().size());
   
    // Done.
    teardown();
  }
View Full Code Here

Examples of org.apache.hadoop.raid.DistBlockIntegrityMonitor.Worker

    final int numBlocks = STRIPE_LENGTH + 1;
    final int repl = 1;
    setup(10, -1);
   
    DistBlockIntegrityMonitor br = new DistBlockRegeneratorFake(conf);
    Worker bc = br.getDecommissioningMonitor();
   
    // Generate file
    Path raidPath = new Path("/raidrs");
   
    Path filePath = new Path("/user/hadoop/testReconstruction/file");
    long[] crcs = createRandomFile(filePath, repl, numBlocks);
    FileStatus file = fileSys.getFileStatus(filePath);
    RaidNode.doRaid(conf, file, raidPath, Codec.getCodec("rs"),
        new RaidNode.Statistics(), RaidUtils.NULL_PROGRESSABLE,
        false, repl, repl);
   
    // Do some testing
    printFileLocations(file);

    // We're gonna "decommission" the file
    TestBlockCopier.decommissioningFiles =
      new String[] { filePath.toUri().toString() };

    // "Decommission" each of the file's blocks in turn
    List<LocatedBlock> fileBlocks =
        dfs.getNameNode().getBlockLocations(filePath.toUri().toString(),
                                            0L,
                                            file.getLen()).getLocatedBlocks();
   

    for (LocatedBlock b : fileBlocks) {
      TestBlockCopier.decommissioningBlocks = new LocatedBlock[] { b };
     
      bc.checkAndReconstructBlocks();
     
      long start = System.currentTimeMillis();
      while ((br.jobsRunning() > 0)
          && ((System.currentTimeMillis() - start) < 30000)) {
        LOG.info("Waiting on block regen jobs to complete ("
            + br.jobsRunning() + " running).");
        Thread.sleep(1000);
        bc.checkJobs();
      }
    }
   
    // Verify that each block now has an extra replica.
    printFileLocations(file);
   
    fileBlocks =
      dfs.getNameNode().getBlockLocations(filePath.toUri().toString(),
          0L,
          file.getLen()).getLocatedBlocks();
    for (LocatedBlock b : fileBlocks) {
      assertEquals("block was improperly replicated",
          repl+1, b.getLocations().length);
    }
    bc.updateStatus();
    assertEquals("unexpected copy failures occurred",
        0, br.getNumFileCopyFailures());
    assertEquals("unexpected number of file copy operations",
        numBlocks, br.getNumFilesCopied());
   
View Full Code Here

Examples of org.apache.isis.runtimes.dflt.remoting.transport.sockets.shared.Worker

                }

                final ServerConnection connection = createServerConnection(inputStream, outputStream, sd);
                // spawnConnectionThread(connection, sd);

                final Worker worker = workerPool.getWorker();
                worker.setIncomingConnection(connection);
                // worker.start();

                // main thread accepts new connection - have a connection -
                // therefore implicitly a request
                // get worker; associate with connection
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.