@Override public Set<File> generateFilePaths(SequencerPoolPartition partition) throws SubmissionException { Set<File> filePaths = new HashSet<File>(); if ((partition.getSequencerPartitionContainer().getRun().getFilePath()) == null) { throw new SubmissionException("No valid run filepath!"); } Pool<? extends Poolable> pool = partition.getPool(); if (pool == null) { throw new SubmissionException("partition.getPool=null!"); } else { Collection<Experiment> experiments = pool.getExperiments(); if (experiments.isEmpty()) { throw new SubmissionException("Collection or experiments is empty"); } else { Collection<? extends Dilution> libraryDilutions = pool.getDilutions(); if (libraryDilutions.isEmpty()) { throw new SubmissionException("Collection of libraryDilutions is empty"); } else { for (Dilution l : libraryDilutions) { Set<File> files = generateFilePath(partition, l); filePaths.addAll(files); } } } } return filePaths; }
public static void createClientCache(String host, Integer port1, Integer port2) throws Exception { PORT1 = port1.intValue(); PORT2 = port2.intValue(); Properties props = new Properties(); props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0"); props.setProperty(DistributionConfig.LOCATORS_NAME, ""); new DestroyEntryPropagationDUnitTest("temp").createCache(props); CacheServerTestUtil.disableShufflingOfEndpoints(); Pool p; try { p = PoolManager.createFactory() .addServer(host, PORT1) .addServer(host, PORT2) .setSubscriptionEnabled(true) .setSubscriptionRedundancy(-1) .setReadTimeout(2000) .setSocketBufferSize(1000) .setMinConnections(4) // .setRetryAttempts(2) // .setRetryInterval(250) .create("EntryPropagationDUnitTestPool"); } finally { CacheServerTestUtil.enableShufflingOfEndpoints(); } AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.DISTRIBUTED_ACK); factory.setPoolName(p.getName()); factory.setCacheListener(new CertifiableTestCacheListener(getLogWriter())); RegionAttributes attrs = factory.create(); cache.createRegion(REGION_NAME, attrs); }
public List<User> getData(String selectSql) { System.out.println(selectSql); List<User> list = null; Pool pool = null; Connection conn = null; Statement stmt = null; try { pool = Pool.getInstance(); conn = pool.getConnection(); stmt = conn.createStatement(); ResultSet rs = stmt.executeQuery(selectSql); list = new ArrayList<User>(); User user = null; while (rs.next()) { user = new User(); user.setAddress(rs.getString("ADDRESS")); user.setAge(rs.getInt("AGE")); user.setGender(rs.getString("GENDER")); user.setID(rs.getString("ID")); user.setLoginname(rs.getString("LOGINNAME")); user.setPassword(rs.getString("PASSWORD")); user.setRepassword(rs.getString("REPASSWORD")); user.setTelephone(rs.getString("TELEPHONE")); user.setUsername(rs.getString("USERNAME")); list.add(user); } rs.close(); } catch (Exception e) { e.printStackTrace(); } return list; }
/** Get all pool names that have been seen either in the allocation file or in a MapReduce job. */ public synchronized Collection<String> getPoolNames() { List<String> list = new ArrayList<String>(); for (Pool pool : getPools()) { list.add(pool.getName()); } Collections.sort(list); return list; }
public void action(ParserEvent e) { if (DEBUG) System.out.println(e); PicPoint pt = (PicPoint) e.getValue(); pool.currentObj.setCtrlPt( ptNumber, pt.toMm(pool.get(PstricksParser.KEY_X_UNIT), pool.get(PstricksParser.KEY_Y_UNIT)), constraint); }
/** Get a pool by name, creating it if necessary */ public synchronized Pool getPool(String name) { Pool pool = pools.get(name); if (pool == null) { pool = new Pool(scheduler, name); pool.setSchedulingMode(defaultSchedulingMode); pools.put(name, pool); } return pool; }
private PoolSummary compilePoolSummary(Pool pool) { PoolSummary.Builder poolSummaryBuilder = aPoolSummary().withPoolName(pool.getName()); for (Device device : pool.getDevices()) { compileResultsForDevice(pool, poolSummaryBuilder, device); } Device watchdog = getPoolWatchdog(pool.getName()); compileResultsForDevice(pool, poolSummaryBuilder, watchdog); return poolSummaryBuilder.build(); }
/** * Creates a pool with a single zero vector in it. * * @param name the name of the pool * @return the pool with the vector */ private Pool<float[]> createDummyVectorPool(String name) { logger.info("creating dummy vector pool " + name); Pool<float[]> pool = new Pool<float[]>(name); float[] vector = new float[vectorLength]; for (int i = 0; i < vectorLength; i++) { vector[i] = 0.0f; } pool.put(0, vector); return pool; }
public void logInfo() { logger.info("Sphinx3Loader"); meansPool.logInfo(logger); variancePool.logInfo(logger); matrixPool.logInfo(logger); senonePool.logInfo(logger); meanTransformationMatrixPool.logInfo(logger); meanTransformationVectorPool.logInfo(logger); varianceTransformationMatrixPool.logInfo(logger); varianceTransformationVectorPool.logInfo(logger); mixtureWeightsPool.logInfo(logger); senonePool.logInfo(logger); logger.info("Context Independent Unit Entries: " + contextIndependentUnits.size()); hmmManager.logInfo(logger); }
/** * get all worksite * * @return */ public WorkSite[] batch() { WorkSite[] sites = null; super.lockMulti(); try { int size = mapSite.size(); if (size > 0) { sites = new WorkSite[size]; mapSite.values().toArray(sites); } } catch (Throwable exp) { Logger.fatal(exp); } finally { super.unlockMulti(); } return sites; }
@Before public void setUp() { config.setProperty(ConfigProperties.INTEGER_ATTRIBUTES, "product.count, product.multiplier"); config.setProperty(ConfigProperties.NON_NEG_INTEGER_ATTRIBUTES, "product.pos_count"); config.setProperty( ConfigProperties.LONG_ATTRIBUTES, "product.long_count, product.long_multiplier"); config.setProperty(ConfigProperties.NON_NEG_LONG_ATTRIBUTES, "product.long_pos_count"); config.setProperty( ConfigProperties.BOOLEAN_ATTRIBUTES, "product.bool_val_str, product.bool_val_num"); this.owner = createOwner(); ownerCurator.create(owner); product = TestUtil.createProduct(owner); productCurator.create(product); providedProduct = TestUtil.createProduct(owner); productCurator.create(providedProduct); Set<Product> providedProducts = new HashSet<Product>(); providedProducts.add(providedProduct); derivedProduct = TestUtil.createProduct(owner); productCurator.create(derivedProduct); derivedProvidedProduct = TestUtil.createProduct(owner); productCurator.create(derivedProvidedProduct); Set<Product> derivedProvidedProducts = new HashSet<Product>(); derivedProvidedProducts.add(derivedProvidedProduct); pool = new Pool( owner, product, providedProducts, 16L, TestUtil.createDate(2006, 10, 21), TestUtil.createDate(2020, 1, 1), "1", "2", "3"); pool.setDerivedProduct(derivedProduct); pool.setDerivedProvidedProducts(derivedProvidedProducts); poolCurator.create(pool); }
@Override public T get() { if (Thread.currentThread() == ownerThread && super.size() > 0) { return super.get(); } else { return synchronizedPool.get(); } }
public void loadPool(Pool pool, String sPool) throws ParseException { try { loadPoolCalled = true; pool.setBucketsUri(new URI(bucketsUri)); } catch (URISyntaxException e) { throw new ParseException(e.getMessage(), 0); } }
/** * Creates a pool with a single identity matrix in it. * * @param name the name of the pool * @return the pool with the matrix */ private Pool<float[][]> createDummyMatrixPool(String name) { Pool<float[][]> pool = new Pool<float[][]>(name); float[][] matrix = new float[vectorLength][vectorLength]; logger.info("creating dummy matrix pool " + name); for (int i = 0; i < vectorLength; i++) { for (int j = 0; j < vectorLength; j++) { if (i == j) { matrix[i][j] = 1.0F; } else { matrix[i][j] = 0.0F; } } } pool.put(0, matrix); return pool; }
@Override public void release(T obj) { if (Thread.currentThread() == ownerThread) { super.release(obj); } else { synchronizedPool.release(obj); } }
@Override public Set<File> generateFilePath(SequencerPoolPartition partition, Dilution l) throws SubmissionException { Pool<? extends Poolable> pool = partition.getPool(); if (pool != null) { if (pool.getExperiments() != null) { Collection<Experiment> experiments = pool.getExperiments(); Experiment experiment = experiments.iterator().next(); StringBuilder filePath = new StringBuilder(); if (!"".equals(basePath)) { filePath.append( partition.getSequencerPartitionContainer().getRun().getFilePath() + "/Data/Intensities/BaseCalls/PAP/Project_" + experiment.getStudy().getProject().getAlias() + "/Sample_" + l.getLibrary().getName() + "/" + l.getLibrary().getName()); } else { filePath.append( basePath + "/" + experiment.getStudy().getProject().getAlias() + "/Sample_" + l.getLibrary().getName() + "/" + l.getLibrary().getName()); } if (l.getLibrary().getTagBarcodes() != null && !l.getLibrary().getTagBarcodes().isEmpty()) { filePath.append("_"); for (TagBarcode tb : l.getLibrary().getTagBarcodes().values()) { filePath.append(tb.getSequence()); } } filePath.append("_L00" + partition.getPartitionNumber() + "*.fastq.gz"); Set<File> files = new HashSet<File>(); files.add(new File(filePath.toString())); return files; } else { throw new SubmissionException("partition.getPool=null!"); } } else { throw new SubmissionException("Collection of experiments is empty"); } }
/** * Cancels pending tasks for given repository. * * @param context request context * @param uuid repository uuid * @return <code>true</code> if has been canceled properly */ public boolean cancel(RequestContext context, String uuid) { LOGGER.log(Level.FINER, "[SYNCHRONIZER] Canceled resource: {0}", uuid); // drop resource already being harvested boolean dropped = pool != null ? pool.drop(uuid) : false; // withdraw from the queue boolean canceled = taskQueue != null ? taskQueue.cancel(context, uuid) : false; // exit with status return canceled || dropped; }
/** * Gets the senone sequence representing the given senones. * * @param stateid is the array of senone state ids * @return the senone sequence associated with the states */ private SenoneSequence getSenoneSequence(int[] stateid) { Senone[] senones = new Senone[stateid.length]; for (int i = 0; i < stateid.length; i++) { senones[i] = senonePool.get(stateid[i]); } // TODO: Is there any advantage in trying to pool these? return new SenoneSequence(senones); }
/** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { /* * Las lineas seguidas por //*** son el codigo para utilizar las clases del * paquete jdbc que tiene ya los metodos para la conección y la consulta y * la clase EmpleadoDTO para guardar un registro de la tabla Employees */ Connection cx = null; Statement st = null; ResultSet rset = null; PrintWriter out = null; String id = request.getParameter("Id"); // *** // int foo = Integer.parseInt(id); //*** try { cx = Pool.getConnection(); st = cx.createStatement(); rset = st.executeQuery("Select * from Employees where employee_id = " + id); String nombre = null; String apellido = null; // EmpleadoDTO emp = new EmpleadoDTO(); //*** // BaseDatos base = new BaseDatos(); //*** // emp = base.leerEmpleado(foo); //*** if (rset.next()) { nombre = rset.getString("first_name"); apellido = rset.getString("last_name"); log.info("Empleado " + nombre + " " + apellido + " recuperado"); } else { log.info("No existe un empleado con este id"); nombre = "No existe un empleado con este id"; } response.setContentType("text/html"); // *** out = response.getWriter(); // *** // out.println(emp.toString()); //*** out.println(nombre + " " + apellido); } catch (Exception e) { e.printStackTrace(); log.error("Error en el hacer la consulta a la base de datos"); out.println("Error en el hacer la consulta a la base de datos"); } finally { Pool.liberarRecursos(cx, st, rset); } }
@Test public void testPools() { try { int expected = getDataSet().getTable("Pool").getRowCount(); int actual = getPoolDAO().count(); TestCase.assertEquals("Wrong number of Pools", expected, actual); System.out.println("Expected number of Pools: " + expected + ", actual: " + actual); for (Pool d : random(getPoolDAO(), actual, 1)) { TestCase.assertNotNull(d); TestCase.assertNotNull(d.getId()); } } catch (Exception e) { e.printStackTrace(); TestCase.fail(); } }
public List<Input.KeyEvent> getKeyEvents() { synchronized (this) { int len = keyEvents.size(); for (int i = 0; i < len; i++) keyEventPool.free(keyEvents.get(i)); keyEvents.clear(); keyEvents.addAll(keyEventsBuffer); keyEventsBuffer.clear(); return keyEvents; } }
@Override public Set<File> generateFilePaths(SequencerPoolPartition partition) throws SubmissionException { log.debug("Generating filepaths for partition " + partition.getId()); Set<File> filePaths = new HashSet<File>(); Pool pool = partition.getPool(); if (pool == null) { throw new SubmissionException("partition.getPool=null!"); } else { Collection<Experiment> experiments = pool.getExperiments(); if (experiments.isEmpty()) { throw new SubmissionException("Collection or experiments is empty"); } else { Collection<LibraryDilution> libraryDilutions = pool.getDilutions(); if (libraryDilutions.isEmpty()) { throw new SubmissionException("Collection or libraryDilutions is empty"); } else { for (Experiment e : experiments) { StringBuilder filePath = new StringBuilder(); filePath.append(partition.getSequencerPartitionContainer().getRun().getFilePath()); filePath.append("/Data/Intensities/BaseCalls/PAP/Project_"); filePath.append(e.getStudy().getProject().getAlias()); filePath.append("/Sample_"); for (LibraryDilution l : libraryDilutions) { // filePath.append(l.getLibrary().getName()+"/"); /* +l.getLibrary().getName()+"_"+l.getLibrary().getTagBarcode().getSequence()); filePath.append("L00"+lane.getPartitionNumber()) */ String folder = filePath.toString() + l.getLibrary().getName() + "/*.fastq.gz"; // System.out.println(folder); File file = new File(folder); filePaths.add(file); } } } } } return (filePaths); }
public void safeResume() { LOGGER.info("[SYNCHRONIZER] Resuming harvester"); if (autoSelector != null) { autoSelector.safeResume(); } if (watchDog != null) { watchDog.safeResume(); } if (pool != null) { pool.safeResume(); } }
/** * Adds a model to the senone pool. * * @param pool the senone pool * @param stateID vector with senone ID for an HMM * @param distFloor the lowest allowed score * @param varianceFloor the lowest allowed variance * @return the senone pool */ private void addModelToSenonePool( Pool<Senone> pool, int[] stateID, float distFloor, float varianceFloor) { assert pool != null; // int numMixtureWeights = mixtureWeightsPool.size(); /* int numMeans = meansPool.size(); int numVariances = variancePool.size(); int numSenones = mixtureWeightsPool.getFeature(NUM_SENONES, 0); int whichGaussian = 0; logger.fine("NG " + numGaussiansPerSenone); logger.fine("NS " + numSenones); logger.fine("NMIX " + numMixtureWeights); logger.fine("NMNS " + numMeans); logger.fine("NMNS " + numVariances); assert numMixtureWeights == numSenones; assert numVariances == numSenones * numGaussiansPerSenone; assert numMeans == numSenones * numGaussiansPerSenone; */ int numGaussiansPerSenone = mixtureWeightsPool.getFeature(NUM_GAUSSIANS_PER_STATE, 0); assert numGaussiansPerSenone > 0; for (int state : stateID) { MixtureComponent[] mixtureComponents = new MixtureComponent[numGaussiansPerSenone]; for (int j = 0; j < numGaussiansPerSenone; j++) { int whichGaussian = state * numGaussiansPerSenone + j; mixtureComponents[j] = new MixtureComponent( meansPool.get(whichGaussian), meanTransformationMatrixPool.get(0), meanTransformationVectorPool.get(0), variancePool.get(whichGaussian), varianceTransformationMatrixPool.get(0), varianceTransformationVectorPool.get(0), distFloor, varianceFloor); } Senone senone = new GaussianMixture(mixtureWeightsPool.get(state), mixtureComponents, state); pool.put(state, senone); } }
/** * Spans new, separate thread exclusively for the resource. * * @param context request context * @param resource resource to harvest * @param maxRecs maximum number of records to harvest (<code>null</code> for no maximum limit) * @param fromDate to harvest only from the specific date (<code>null</code> for no from date) * @return <code>true</code> if task has been sumbited */ public boolean span(RequestContext context, HrRecord resource, Integer maxRecs, Date fromDate) { if (resource == null) throw new IllegalArgumentException("No resource to harvest provided."); // create instance of the task // add only if no similar task currently executing boolean submitted = false; if (resource.getApprovalStatus() == ApprovalStatus.approved && resource.getSynchronizable()) { CommonCriteria criteria = new CommonCriteria(); criteria.setMaxRecords(maxRecs); criteria.setFromDate(fromDate); submitted = pool != null && taskQueue != null ? !pool.isExecuting(resource.getUuid()) && taskQueue.register(context, resource, criteria) : false; if (submitted) pool.span(resource, criteria); LOGGER.log( Level.FINER, "[SYNCHRONIZER] Submitted resource: {0} ({1})", new Object[] {resource.getUuid(), resource.getName()}); } return submitted; }
/** check timeout site */ private void check() { int size = mapTime.size(); if (size == 0) return; ArrayList<SiteHost> dels = new ArrayList<SiteHost>(size); ArrayList<SiteHost> notifys = new ArrayList<SiteHost>(size); super.lockSingle(); try { long nowTime = System.currentTimeMillis(); for (SiteHost host : mapTime.keySet()) { Long value = mapTime.get(host); if (value == null) { dels.add(host); continue; } long time = value.longValue(); if (nowTime - time >= deleteTime) { dels.add(host); } else if (nowTime - time >= refreshTimeout) { notifys.add(host); } } } catch (Throwable exp) { exp.printStackTrace(); } finally { super.unlockSingle(); } // remove timeout site for (SiteHost host : dels) { Logger.error("WorkPool.check, delete timeout site:%s", host); remove(host); } // notify site SiteHost listen = Launcher.getInstance().getLocalHost(); for (SiteHost host : notifys) { Logger.warning("WorkPool.check, notify timeout site:%s", host); this.sendTimeout(host, listen, 2); } }
@Override public void run() { Random randomGenerator = new Random(); while (true) { int pause; try { pause = randomGenerator.nextInt(500); Thread.sleep(pause); } catch (InterruptedException ex) { System.out.println("consumer " + name + " failed to wait"); } try { String stand = p.read(); System.out.println(name + " getting " + stand); pause = randomGenerator.nextInt(500); Thread.sleep(pause); p.leave(stand); } catch (InterruptedException ex) { Logger.getLogger(Visitor.class.getName()).log(Level.SEVERE, null, ex); } } }
/** @param args */ public static void main(String[] args) { Pool p = new Pool(); p.start(); try { Thread.sleep(50); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } for (int i = 0; i < 20; i++) { Usuario us = new Usuario(p); us.start(); try { Thread.sleep((int) Math.random() * 300); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
@Override public File generateFilePath(SequencerPoolPartition partition, LibraryDilution l) throws SubmissionException { log.debug("Generating filepaths for partition " + partition.getId()); Pool pool = partition.getPool(); if (pool != null) { if (pool.getExperiments() != null) { Collection<Experiment> experiments = pool.getExperiments(); Experiment experiment = experiments.iterator().next(); // String filePath = // lane.getFlowcell().getRun().getFilePath()+"/Data/Intensities/BaseCalls/PAP/Project_"+ String filePath = partition.getSequencerPartitionContainer().getRun().getFilePath() + "/Data/Intensities/BaseCalls/PAP/Project_" + experiment.getStudy().getProject().getAlias() + "/Sample_" + l.getLibrary().getName() + "/" + l.getLibrary().getName() + "_" + l.getLibrary().getTagBarcode().getSequence() + "_L00" + partition.getPartitionNumber() + "*.fastq.gz"; // System.out.println(filePath); File file = new File(filePath); return (file); } else { throw new SubmissionException("partition.getPool=null!"); } } else { throw new SubmissionException("Collection of experiments is empty"); } }
/** Shuts down harvesting engine. */ @Override public void shutdown() { if (getRunning()) { LOGGER.info("[SYNCHRONIZER] Shutting down synchronizer."); if (autoSelector != null) autoSelector.shutdown(); autoSelector = null; if (watchDog != null) watchDog.shutdown(); watchDog = null; if (pool != null) pool.shutdown(); pool = null; taskQueue = null; } else { LOGGER.info("[SYNCHRONIZER] Synchronizer shutted down already."); } }