Java Code Examples for java.util.TreeSet#addAll()

The following examples show how to use java.util.TreeSet#addAll() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChronoGraph.java    From epcis with Apache License 2.0 6 votes vote down vote up
public TreeSet<Long> getTimestamps(Long startTime, Long endTime) {
	TreeSet<Long> timestampSet = new TreeSet<Long>();

	Function<BsonDateTime, Long> mapper = new Function<BsonDateTime, Long>() {
		@Override
		public Long apply(BsonDateTime val) {
			return val.getValue();
		}

	};
	edgeEvents.distinct(Tokens.TIMESTAMP, BsonDateTime.class)
			.filter(new BsonDocument(Tokens.TIMESTAMP,
					new BsonDocument(Tokens.FC.$gt.toString(), new BsonDateTime(startTime))
							.append(Tokens.FC.$lt.toString(), new BsonDateTime(endTime))))
			.map(mapper).into(timestampSet);
	Set<Long> vtSet = new TreeSet<Long>();

	vertexEvents.distinct(Tokens.TIMESTAMP, BsonDateTime.class)
			.filter(new BsonDocument(Tokens.TIMESTAMP,
					new BsonDocument(Tokens.FC.$gt.toString(), new BsonDateTime(startTime))
							.append(Tokens.FC.$lt.toString(), new BsonDateTime(endTime))))
			.map(mapper).into(timestampSet);
	timestampSet.addAll(vtSet);

	return timestampSet;
}
 
Example 2
Source File: PdfWorksheet.java    From unitime with Apache License 2.0 6 votes vote down vote up
public static boolean print(OutputStream out, Collection<SubjectArea> subjectAreas) throws IOException, DocumentException {
    TreeSet courses = new TreeSet(new Comparator() {
        public int compare(Object o1, Object o2) {
            CourseOffering co1 = (CourseOffering)o1;
            CourseOffering co2 = (CourseOffering)o2;
            int cmp = co1.getCourseName().compareTo(co2.getCourseName());
            if (cmp != 0) return cmp;
            return co1.getUniqueId().compareTo(co2.getUniqueId());
        }
    });
    String subjectIds = "";
    for (SubjectArea sa: subjectAreas)
    	subjectIds += (subjectIds.isEmpty() ? "" : ",") + sa.getUniqueId();
    courses.addAll(SessionDAO.getInstance().getSession().createQuery(
    		"select co from CourseOffering co where  co.subjectArea.uniqueId in (" + subjectIds + ")").list());
    if (courses.isEmpty()) return false;
    PdfWorksheet w = new PdfWorksheet(out, subjectAreas, null);
    for (Iterator i=courses.iterator();i.hasNext();) {
        w.print((CourseOffering)i.next());
    }
    w.lastPage();
    w.close();
    return true;
}
 
Example 3
Source File: PdfClassListTableBuilder.java    From unitime with Apache License 2.0 6 votes vote down vote up
protected TreeSet getExams(Class_ clazz) {
    //exams directly attached to the given class
    TreeSet ret = new TreeSet(Exam.findAll(ExamOwner.sOwnerTypeClass, clazz.getUniqueId()));
    //check whether the given class is of the first subpart of the config
    SchedulingSubpart subpart = clazz.getSchedulingSubpart();
    if (subpart.getParentSubpart()!=null) return ret; 
    InstrOfferingConfig config = subpart.getInstrOfferingConfig();
    SchedulingSubpartComparator cmp = new SchedulingSubpartComparator();
    for (Iterator i=config.getSchedulingSubparts().iterator();i.hasNext();) {
        SchedulingSubpart s = (SchedulingSubpart)i.next();
        if (cmp.compare(s,subpart)<0) return ret;
    }
    InstructionalOffering offering = config.getInstructionalOffering();
    //check passed -- add config/offering/course exams to the class exams
    ret.addAll(Exam.findAll(ExamOwner.sOwnerTypeConfig, config.getUniqueId()));
    ret.addAll(Exam.findAll(ExamOwner.sOwnerTypeOffering, offering.getUniqueId()));
    for (Iterator i=offering.getCourseOfferings().iterator();i.hasNext();) {
        CourseOffering co = (CourseOffering)i.next();
        ret.addAll(Exam.findAll(ExamOwner.sOwnerTypeCourse, co.getUniqueId()));
    }
    return ret;
}
 
Example 4
Source File: ModuleTableViewer.java    From hybris-commerce-eclipse-plugin with Apache License 2.0 6 votes vote down vote up
@Override
public Object[] getElements(Object parent) {
	Set<ExtensionHolder> allExtensions = emc.getAllPlatformExtensions();
	if (allExtensions != null) {
		TreeSet<ExtensionHolder> sortedExtensions = new TreeSet<ExtensionHolder>(new Comparator<ExtensionHolder>() {
			@Override
			public int compare(final ExtensionHolder object1, final ExtensionHolder object2) {
				return object1.getName().compareTo(object2.getName());
			}
		});
		sortedExtensions.addAll(allExtensions);
		
		return sortedExtensions.toArray();
	}
	return null;
}
 
Example 5
Source File: SubsetIterator.java    From pumpernickel with MIT License 6 votes vote down vote up
private Set<E> newSet() {
	if (comparator != null)
		return new TreeSet<E>(comparator);

	/*
	 * Unfortunately (I think?) we can't really know until runtime if we our
	 * elements are Comparable<E>, so we'll have to test to be safe:
	 */
	if (useTreeSets == null) {
		try {
			TreeSet<E> test = new TreeSet<E>();
			test.addAll(elements);
			useTreeSets = Boolean.TRUE;
		} catch (Exception e) {
			useTreeSets = Boolean.FALSE;
		}
	}

	if (useTreeSets)
		return new TreeSet<E>();

	return new HashSet<E>();
}
 
Example 6
Source File: ExamRoomSplit.java    From cpsolver with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * generate report
 * @param assignment current assignment
 * @return resultant report
 */
public CSVFile report(Assignment<Exam, ExamPlacement> assignment) {
    CSVFile csv = new CSVFile();
    csv.setHeader(new CSVField[] { new CSVField("Exam"), new CSVField("Enrl"), new CSVField("Period"),
            new CSVField("Date"), new CSVField("Time"), new CSVField("Room 1"), new CSVField("Cap 1"),
            new CSVField("Room 2"), new CSVField("Cap 2"), new CSVField("Room 3"), new CSVField("Cap 3"),
            new CSVField("Room 4"), new CSVField("Cap 4") });
    for (Exam exam : iModel.variables()) {
        ExamPlacement placement = assignment.getValue(exam);
        if (placement == null || placement.getRoomPlacements().size() <= 1)
            continue;
        List<CSVField> fields = new ArrayList<CSVField>();
        fields.add(new CSVField(exam.getName()));
        fields.add(new CSVField(exam.getStudents().size()));
        fields.add(new CSVField(placement.getPeriod().getIndex() + 1));
        fields.add(new CSVField(placement.getPeriod().getDayStr()));
        fields.add(new CSVField(placement.getPeriod().getTimeStr()));
        TreeSet<ExamRoomPlacement> rooms = new TreeSet<ExamRoomPlacement>(new ExamRoomComparator(exam, false));
        rooms.addAll(placement.getRoomPlacements());
        for (ExamRoomPlacement room : rooms) {
            fields.add(new CSVField(room.getName()));
            fields.add(new CSVField(room.getSize(exam.hasAltSeating())));
        }
        csv.addLine(fields);
    }
    return csv;
}
 
Example 7
Source File: CrashHandler.java    From letv with Apache License 2.0 5 votes vote down vote up
private void sendCrashReportsToServer(Context ctx) {
    String[] crFiles = getCrashReportFiles(ctx);
    if (crFiles != null && crFiles.length > 0) {
        TreeSet<String> sortedFiles = new TreeSet();
        sortedFiles.addAll(Arrays.asList(crFiles));
        Iterator it = sortedFiles.iterator();
        while (it.hasNext()) {
            File cr = new File(ctx.getFilesDir(), (String) it.next());
            postReport(cr);
            cr.delete();
        }
    }
}
 
Example 8
Source File: Department.java    From unitime with Apache License 2.0 5 votes vote down vote up
public static TreeSet<Department> getUserDepartments(UserContext user) {
	TreeSet<Department> departments = new TreeSet<Department>();
	if (user == null || user.getCurrentAuthority() == null) return departments;
	if (user.getCurrentAuthority().hasRight(Right.DepartmentIndependent))
		departments.addAll(Department.findAllBeingUsed(user.getCurrentAcademicSessionId()));
	else
		for (UserQualifier q: user.getCurrentAuthority().getQualifiers("Department"))
			departments.add(DepartmentDAO.getInstance().get((Long)q.getQualifierId()));
	return departments;
}
 
Example 9
Source File: PaymentInfoBean.java    From development with Apache License 2.0 5 votes vote down vote up
public Collection<VOPaymentType> getEnabledPaymentTypes(Long key, AccountService accountService) {
    TreeSet<VOPaymentType> enabledPaymentTypes = null;
    try{
        enabledPaymentTypes =  new TreeSet<>(paymentTypeComparator);
        enabledPaymentTypes.addAll(accountService
                .getAvailablePaymentTypesFromOrganization(
                        key));
    } catch (SaaSApplicationException e) {
        ExceptionHandler.execute(e);
    }
    return enabledPaymentTypes;
}
 
Example 10
Source File: ClusterManager.java    From flex-blazeds with Apache License 2.0 5 votes vote down vote up
/**
 * Used for targeted endpoint operation invocations across the cluster.
 * If a default cluster is defined, its list of member addresses is returned.
 * Otherwise, a de-duped list of all member addresses from all registered clusters is returned.
 *
 * @return The list of cluster nodes that endpoint operation invocations can be issued against.
 */
public List getClusterMemberAddresses()
{
    if (defaultCluster != null)
        return defaultCluster.getMemberAddresses();

    TreeSet uniqueAddresses = new TreeSet();
    for (Cluster cluster : clusters.values())
        uniqueAddresses.addAll(cluster.getMemberAddresses());

    return new ArrayList(uniqueAddresses);
}
 
Example 11
Source File: LuceneDataStoreSearchGUI.java    From gate-core with GNU Lesser General Public License v3.0 5 votes vote down vote up
protected void updateAnnotationSetsList() {
  String corpusName =
          (corpusToSearchIn.getSelectedItem()
                  .equals(Constants.ENTIRE_DATASTORE))
                  ? null
                  : (String)corpusIds
                          .get(corpusToSearchIn.getSelectedIndex() - 1);
  TreeSet<String> ts = new TreeSet<String>(stringCollator);
  ts.addAll(getAnnotationSetNames(corpusName));
  DefaultComboBoxModel<String> dcbm = new DefaultComboBoxModel<String>(ts.toArray(new String[ts.size()]));
  dcbm.insertElementAt(Constants.ALL_SETS, 0);
  annotationSetsToSearchIn.setModel(dcbm);
  annotationSetsToSearchIn.setSelectedItem(Constants.ALL_SETS);

  // used in the ConfigureStackViewFrame as Annotation type column
  // cell editor
  TreeSet<String> types = new TreeSet<String>(stringCollator);
  types.addAll(getTypesAndFeatures(null, null).keySet());
  // put all annotation types from the datastore
  // combobox used as cell editor
  JComboBox<String> annotTypesBox = new JComboBox<String>();
  annotTypesBox.setMaximumRowCount(10);
  annotTypesBox.setModel(new DefaultComboBoxModel<String>(types.toArray(new String[types.size()])));
  DefaultCellEditor cellEditor = new DefaultCellEditor(annotTypesBox);
  cellEditor.setClickCountToStart(0);
  configureStackViewFrame.getTable().getColumnModel()
          .getColumn(ANNOTATION_TYPE).setCellEditor(cellEditor);
}
 
Example 12
Source File: FindMendelianViolations.java    From picard with MIT License 5 votes vote down vote up
private void writeAllViolations(final MendelianViolationDetector.Result result) {
    if (VCF_DIR != null) {
        LOG.info(String.format("Writing family violation VCFs to %s/", VCF_DIR.getAbsolutePath()));

        final VariantContextComparator vcComparator = new VariantContextComparator(inputHeader.get().getContigLines());
        final Set<VCFHeaderLine> headerLines = new LinkedHashSet<>(inputHeader.get().getMetaDataInInputOrder());

        headerLines.add(new VCFInfoHeaderLine(MendelianViolationDetector.MENDELIAN_VIOLATION_KEY, 1, VCFHeaderLineType.String, "Type of mendelian violation."));
        headerLines.add(new VCFInfoHeaderLine(MendelianViolationDetector.ORIGINAL_AC, VCFHeaderLineCount.A, VCFHeaderLineType.Integer, "Original AC"));
        headerLines.add(new VCFInfoHeaderLine(MendelianViolationDetector.ORIGINAL_AF, VCFHeaderLineCount.A, VCFHeaderLineType.Float, "Original AF"));
        headerLines.add(new VCFInfoHeaderLine(MendelianViolationDetector.ORIGINAL_AN, 1, VCFHeaderLineType.Integer, "Original AN"));

        for (final PedFile.PedTrio trio : pedFile.get().values()) {
            final File outputFile = new File(VCF_DIR, IOUtil.makeFileNameSafe(trio.getFamilyId() + IOUtil.VCF_FILE_EXTENSION));
            LOG.info(String.format("Writing %s violation VCF to %s", trio.getFamilyId(), outputFile.getAbsolutePath()));

            final VariantContextWriter out = new VariantContextWriterBuilder()
                    .setOutputFile(outputFile)
                    .unsetOption(INDEX_ON_THE_FLY)
                    .build();

            final VCFHeader newHeader = new VCFHeader(headerLines, CollectionUtil.makeList(trio.getMaternalId(), trio.getPaternalId(), trio.getIndividualId()));
            final TreeSet<VariantContext> orderedViolations = new TreeSet<>(vcComparator);

            orderedViolations.addAll(result.violations().get(trio.getFamilyId()));
            out.writeHeader(newHeader);
            orderedViolations.forEach(out::add);

            out.close();
        }
    }
}
 
Example 13
Source File: TimetableManager.java    From unitime with Apache License 2.0 5 votes vote down vote up
public Set getDistributionPreferences(Session session) {
	TreeSet prefs = new TreeSet();
	for (Iterator i=departmentsForSession(session.getUniqueId()).iterator();i.hasNext();) {
		Department d = (Department)i.next();
		prefs.addAll(d.getDistributionPreferences());
	}    	
	return prefs;
}
 
Example 14
Source File: LoggingFilter.java    From timbuctoo with GNU General Public License v3.0 4 votes vote down vote up
private Set<Map.Entry<String, List<String>>> getSortedHeaders(final Set<Map.Entry<String, List<String>>> headers) {
  final TreeSet<Map.Entry<String, List<String>>> sortedHeaders = new TreeSet<>(COMPARATOR);
  sortedHeaders.addAll(headers);
  return sortedHeaders;
}
 
Example 15
Source File: EvictionBehaviorTest.java    From gemfirexd-oss with Apache License 2.0 4 votes vote down vote up
protected void verifyIncrementalEviction() {
  int totalNumBuckets = aRegion.getPartitionAttributes().getTotalNumBuckets();
  int numDeviatedBuckets = 0; // Number of buckets that deviated from expected
                              // eviction

  // We cannot check percentage eviction because lower size buckets may not
  // evict and this can cause test to fail
  // Will verify that the fatter buckets will evict more.

  Set<Map.Entry<Integer, BucketRegion>> bucketList = aRegion.getDataStore()
      .getAllLocalBuckets();
  Comparator<Map.Entry<Integer, BucketRegion>> comparator = new Comparator<Map.Entry<Integer, BucketRegion>>() {

    public int compare(Entry<Integer, BucketRegion> o1,
        Entry<Integer, BucketRegion> o2) {
      if (o1.getKey() < o2.getKey()) {
        return -1;
      }
      else if (o1.getKey() > o2.getKey()) {
        return 1;
      }
      else {
        return 0;
      }
    }
  };

  TreeSet<Map.Entry<Integer, BucketRegion>> sortedBucketSet = new TreeSet<Entry<Integer, BucketRegion>>(
      comparator);
  sortedBucketSet.addAll(bucketList);

  Iterator iterator = sortedBucketSet.iterator();
  StringBuffer errorString = new StringBuffer();

  int previousBucketId = -1;
  long previousBucketEviction = 0;
  long previousBucketSize = 0;

  while (iterator.hasNext()) {
    Map.Entry entry = (Map.Entry)iterator.next();
    BucketRegion bucket = (BucketRegion)entry.getValue();
    int bucketId = ((BucketRegion)bucket).getId();
    long numEvictionsForBucket = ((BucketRegion)bucket).getEvictions();
    long bucketSize;
    try {
      bucketSize = ((BucketRegion)bucket).getNumEntriesInVM()
          + ((BucketRegion)bucket).getNumOverflowOnDisk();

    }
    catch (Exception e) {
      throw new TestException("Caught ", e);
    }
    float bucketEvictionPercentage = ((float)numEvictionsForBucket * 100)
        / bucketSize;
    
    if (bucketEvictionPercentage == 100) {
      throw new TestException("For the bucket region with id " + bucketId
          + " bucket evicted all entries");
    }

    if ((numEvictionsForBucket < previousBucketEviction)
        && (bucketSize > previousBucketSize)) {
      errorString.append("For the bucket region with id " + bucketId
          + " with size " + bucketSize + " numEvicted is "
          + numEvictionsForBucket + " but leaner bucket with id "
          + previousBucketId + " with bucket size " + previousBucketSize
          + " evicted more entries " + previousBucketEviction + "\n");
      numDeviatedBuckets++;
      if (numDeviatedBuckets > totalNumBuckets * 0.1) {
        //10% Tolerance for number of deviation as this can happen because of bucket sorting time interval
        throw new TestException(errorString);
      }
      hydra.Log.getLogWriter().info(
          "For the bucket region with id " + bucketId + " with size "
              + bucketSize + " numEvicted is " + numEvictionsForBucket
              + " but leaner bucket with id " + previousBucketId
              + " with bucket size " + previousBucketSize
              + " evicted more entries " + previousBucketEviction);
    }
    else {
      String s = "For the bucket region with id " + bucketId + " with size "
          + bucketSize + " numEvicted is " + numEvictionsForBucket
          + " and leaner bucket with id " + previousBucketId
          + " with bucket size " + previousBucketSize
          + " evicted lesser entries " + previousBucketEviction;
      hydra.Log.getLogWriter().info(s);
    }
    previousBucketId = bucketId;
    previousBucketEviction = numEvictionsForBucket;
    previousBucketSize = bucketSize;
  }
}
 
Example 16
Source File: TranslationReport.java    From freecol with GNU General Public License v2.0 4 votes vote down vote up
private static TreeSet<String> sort(ArrayList<String> missingKeys) {
    TreeSet<String> sorted = new TreeSet<>();
    sorted.addAll(missingKeys);
    return sorted;
}
 
Example 17
Source File: ResidenceYear.java    From fenixedu-academic with GNU Lesser General Public License v3.0 4 votes vote down vote up
public Set<ResidenceMonth> getSortedMonths() {
    TreeSet<ResidenceMonth> months = new TreeSet<>(Comparator.comparing(ResidenceMonth::getMonth));
    months.addAll(getMonthsSet());
    return months;
}
 
Example 18
Source File: SolutionReportAction.java    From unitime with Apache License 2.0 4 votes vote down vote up
public PdfWebTable getRoomReportTable(HttpServletRequest request, RoomReport report, boolean noHtml, Long type) {
	WebTable.setOrder(sessionContext,"solutionReports.roomReport.ord",request.getParameter("room_ord"),-1);
	String name = "Room Allocation - "+(type==null?"Non University Locations":RoomTypeDAO.getInstance().get(type).getLabel());
       PdfWebTable webTable = new PdfWebTable( 9,
  	        	name, "solutionReport.do?room_ord=%%",
  				new String[] {"Group", "Size", "NrRooms*", "ClUse", "ClShould", "ClMust*", "HrUse", "HrShould", "HrMust*"},
  				new String[] {"center", "center", "left","left","left","left","left","left","left"},
  				null);
       webTable.setRowStyle("white-space:nowrap");
       int nrLines = 0;
       
       try {
           int nrAllRooms = 0, nrAllLectureUse = 0, nrAllLectureShouldUse = 0;
           double allSlotsUse = 0.0, allSlotsShouldUse = 0.0;
           
           TreeSet groups = new TreeSet(new Comparator() {
               public int compare(Object o1, Object o2) {
                   RoomReport.RoomAllocationGroup g1 = (RoomReport.RoomAllocationGroup)o1;
                   RoomReport.RoomAllocationGroup g2 = (RoomReport.RoomAllocationGroup)o2;
                   return -Double.compare(g1.getMinRoomSize(),g2.getMinRoomSize());
               }
           });
           groups.addAll(report.getGroups());
           
       	for (Iterator i=groups.iterator();i.hasNext();) {
       		RoomReport.RoomAllocationGroup g = (RoomReport.RoomAllocationGroup)i.next();
       		if (g.getNrRooms()==0) continue;
       		
       		double factor = ((double)Constants.SLOT_LENGTH_MIN) / 60.0;
               
               nrAllRooms+=g.getNrRooms();
               allSlotsUse+=g.getSlotsUse();
               allSlotsShouldUse+=g.getSlotsShouldUse();
               nrAllLectureUse+=g.getLecturesUse();
               nrAllLectureShouldUse+=g.getLecturesShouldUse();
               
               nrLines++;
       		
       		webTable.addLine(null,
   	    		new String[] {
       				g.getMinRoomSize()+" ... "+(g.getMaxRoomSize()==Integer.MAX_VALUE?(noHtml?"inf":"<i>inf</i>"):String.valueOf(g.getMaxRoomSize())),
       				g.getActualMinRoomSize()+" ... "+g.getActualMaxRoomSize(),
       				g.getNrRooms()+" ("+g.getNrRoomsThisSizeOrBigger()+")",
       				//""+g.getLecturesCanUse(),
       				""+g.getLecturesUse()+" ("+nrAllLectureUse+")",
       				""+g.getLecturesShouldUse()+" ("+nrAllLectureShouldUse+")",
       				g.getLecturesMustUse()+" ("+g.getLecturesMustUseThisSizeOrBigger()+")",
       				//sDoubleFormat.format(factor*g.getSlotsCanUse()/g.getNrRooms()),
       				sDoubleFormat.format(factor*g.getSlotsUse()/g.getNrRooms())+" ("+sDoubleFormat.format(factor*allSlotsUse/nrAllRooms)+")",
       				sDoubleFormat.format(factor*g.getSlotsShouldUse()/g.getNrRooms())+" ("+sDoubleFormat.format(factor*allSlotsShouldUse/nrAllRooms)+")",
       				sDoubleFormat.format(factor*g.getSlotsMustUse()/g.getNrRooms())+" ("+sDoubleFormat.format(factor*g.getSlotsMustUseThisSizeOrBigger()/g.getNrRoomsThisSizeOrBigger())+")"
       			},
       			new Comparable[] {
       				new Integer(g.getMinRoomSize()),
       				new Integer(g.getActualMinRoomSize()),
       				new Integer(g.getNrRooms()),
       				//new Integer(g.getLecturesCanUse()),
       				new Integer(g.getLecturesUse()),
       				new Integer(g.getLecturesShouldUse()),
       				new Integer(g.getLecturesMustUse()),
       				//new Double(factor*g.getSlotsCanUse()/g.getNrRooms()),
       				new Double(factor*g.getSlotsUse()/g.getNrRooms()),
       				new Double(factor*g.getSlotsShouldUse()/g.getNrRooms()),
       				new Double(factor*g.getSlotsMustUse()/g.getNrRooms())
       			});
       	}
       } catch (Exception e) {
       	Debug.error(e);
       	webTable.addLine(new String[] {"<font color='red'>ERROR:"+e.getMessage()+"</font>"},null);
           nrLines++;
       }
       if (nrLines==0) return null;
       return webTable;
}
 
Example 19
Source File: ClusterListSubCommand.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
private void printClusterMoreStats(final DefaultMQAdminExt defaultMQAdminExt) throws RemotingConnectException,
    RemotingTimeoutException, RemotingSendRequestException, InterruptedException, MQBrokerException {

    ClusterInfo clusterInfoSerializeWrapper = defaultMQAdminExt.examineBrokerClusterInfo();

    System.out.printf("%-16s  %-32s %14s %14s %14s %14s%n",
        "#Cluster Name",
        "#Broker Name",
        "#InTotalYest",
        "#OutTotalYest",
        "#InTotalToday",
        "#OutTotalToday"
    );

    Iterator<Map.Entry<String, Set<String>>> itCluster = clusterInfoSerializeWrapper.getClusterAddrTable().entrySet().iterator();
    while (itCluster.hasNext()) {
        Map.Entry<String, Set<String>> next = itCluster.next();
        String clusterName = next.getKey();
        TreeSet<String> brokerNameSet = new TreeSet<String>();
        brokerNameSet.addAll(next.getValue());

        for (String brokerName : brokerNameSet) {
            BrokerData brokerData = clusterInfoSerializeWrapper.getBrokerAddrTable().get(brokerName);
            if (brokerData != null) {

                Iterator<Map.Entry<Long, String>> itAddr = brokerData.getBrokerAddrs().entrySet().iterator();
                while (itAddr.hasNext()) {
                    Map.Entry<Long, String> next1 = itAddr.next();
                    long inTotalYest = 0;
                    long outTotalYest = 0;
                    long inTotalToday = 0;
                    long outTotalToday = 0;

                    try {
                        KVTable kvTable = defaultMQAdminExt.fetchBrokerRuntimeStats(next1.getValue());
                        String msgPutTotalYesterdayMorning = kvTable.getTable().get("msgPutTotalYesterdayMorning");
                        String msgPutTotalTodayMorning = kvTable.getTable().get("msgPutTotalTodayMorning");
                        String msgPutTotalTodayNow = kvTable.getTable().get("msgPutTotalTodayNow");
                        String msgGetTotalYesterdayMorning = kvTable.getTable().get("msgGetTotalYesterdayMorning");
                        String msgGetTotalTodayMorning = kvTable.getTable().get("msgGetTotalTodayMorning");
                        String msgGetTotalTodayNow = kvTable.getTable().get("msgGetTotalTodayNow");

                        inTotalYest = Long.parseLong(msgPutTotalTodayMorning) - Long.parseLong(msgPutTotalYesterdayMorning);
                        outTotalYest = Long.parseLong(msgGetTotalTodayMorning) - Long.parseLong(msgGetTotalYesterdayMorning);

                        inTotalToday = Long.parseLong(msgPutTotalTodayNow) - Long.parseLong(msgPutTotalTodayMorning);
                        outTotalToday = Long.parseLong(msgGetTotalTodayNow) - Long.parseLong(msgGetTotalTodayMorning);

                    } catch (Exception e) {
                    }

                    System.out.printf("%-16s  %-32s %14d %14d %14d %14d%n",
                        clusterName,
                        brokerName,
                        inTotalYest,
                        outTotalYest,
                        inTotalToday,
                        outTotalToday
                    );
                }
            }
        }

        if (itCluster.hasNext()) {
            System.out.printf("");
        }
    }
}
 
Example 20
Source File: GraphReportManager.java    From constellation with Apache License 2.0 3 votes vote down vote up
/**
 * Get the tags that are being ignored (not recorded) by GraphReport. A
 * {@link PluginReport} will be ignored if all of its tags are present in
 * the this collection of ignored tags. If any of a {@link PluginReport}s
 * tags are not in this list, it will not be ignored. When a
 * {@link PluginReport} is ignored, it is completely discarded as if it
 * never occurred. This is different
 * <p>
 * The tags will be remembered in user preferences so they persist between
 * sessions.
 *
 * @return The tags that are being ignored (not recorded) by GraphReport.
 * @see GraphReportManager#setIgnoredTags(java.util.Collection)
 */
public static synchronized Set<String> getIgnoredTags() {
    final TreeSet<String> tags = new TreeSet<>();
    tags.addAll(IGNORED_TAGS);

    return tags;
}