private void deploy() { List startList = new ArrayList(); Iterator iter = dirMap.entrySet().iterator(); try { while (iter.hasNext() && !shutdown) { Map.Entry entry = (Map.Entry) iter.next(); File f = (File) entry.getKey(); QEntry qentry = (QEntry) entry.getValue(); long deployed = qentry.getDeployed(); if (deployed == 0) { if (deploy(f)) { if (qentry.isQBean()) startList.add(qentry.getInstance()); qentry.setDeployed(f.lastModified()); } else { // deploy failed, clean up. iter.remove(); } } else if (deployed != f.lastModified()) { undeploy(f); iter.remove(); loader.forceNewClassLoaderOnNextScan(); } } iter = startList.iterator(); while (iter.hasNext()) { start((ObjectInstance) iter.next()); } } catch (Exception e) { log.error("deploy", e); } }
public void changeClassLabels() { System.out.println("Reading cluster file: " + cluserInputFile); Clusters clusters = loadClusters(cluserInputFile); if (clusters == null) { System.out.println("Not clusters found to change"); return; } Map<Integer, String> classToSector = new HashMap<Integer, String>(); for (Map.Entry<String, Integer> e : sectorToClazz.entrySet()) { classToSector.put(e.getValue(), e.getKey()); } for (Cluster c : clusters.getCluster()) { // find the cluster label // this is the label String key = classToSector.get(c.getKey()); if (key != null) { System.out.println("Setting label: " + key + " to cluster: " + c.getKey()); c.setLabel(key); } } try { System.out.println("Writing cluster file: " + clusterOutputFile); saveClusters(clusterOutputFile, clusters); } catch (FileNotFoundException | JAXBException e) { throw new RuntimeException("Failed to write clusters", e); } }
private void init() { permNoToSymbol = Utils.loadMapping(originalStockFile); Map<String, Integer> symbolToPerm = new HashMap<String, Integer>(); for (Map.Entry<Integer, String> entry : permNoToSymbol.entrySet()) { symbolToPerm.put(entry.getValue(), entry.getKey()); } }
private void undeploy() { Object[] set = dirMap.entrySet().toArray(); int l = set.length; while (l-- > 0) { Map.Entry entry = (Map.Entry) set[l]; File f = (File) entry.getKey(); undeploy(f); } }
private void checkModified() { Iterator iter = dirMap.entrySet().iterator(); while (iter.hasNext()) { Map.Entry entry = (Map.Entry) iter.next(); File f = (File) entry.getKey(); QEntry qentry = (QEntry) entry.getValue(); if (qentry.isQBean() && qentry.isQPersist()) { ObjectName name = qentry.getObjectName(); if (getState(name) == QBean.STARTED && isModified(name)) { qentry.setDeployed(persist(f, name)); } } } }
public void process() { File inFolder = new File(vectorFolder); if (!inFolder.isDirectory()) { System.out.println("In should be a folder: " + vectorFolder); return; } boolean clusterSaved = false; this.invertedFixedClases = loadFixedClasses(fixedClassesFile); if (!histogram) { Map<String, List<String>> sectors = loadStockSectors(sectorFile); sectorToClazz = convertSectorsToClazz(sectors); if (!clusterSaved) { changeClassLabels(); clusterSaved = true; } for (Map.Entry<String, Integer> entry : sectorToClazz.entrySet()) { System.out.println(entry.getKey() + " : " + entry.getValue()); } } for (File inFile : inFolder.listFiles()) { String fileName = inFile.getName(); String fileNameWithOutExt = FilenameUtils.removeExtension(fileName); if (histogram) { sectorToClazz.clear(); invertedSectors.clear(); Map<String, List<String>> sectors = loadHistoSectors(sectorFile + "/" + fileNameWithOutExt + ".csv"); sectorToClazz = convertSectorsToClazz(sectors); if (!clusterSaved) { changeClassLabels(); clusterSaved = true; } for (Map.Entry<String, Integer> entry : sectorToClazz.entrySet()) { System.out.println(entry.getKey() + " : " + entry.getValue()); } } processFile(fileNameWithOutExt); } }