java.util.LinkedList Java Examples

The following examples show how to use java.util.LinkedList. 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 Project: openjdk-jdk9   Author: AdoptOpenJDK   File: NetworkConfiguration.java    License: GNU General Public License v2.0 8 votes vote down vote up
/**
 * Return a NetworkConfiguration instance.
 */
public static NetworkConfiguration probe() throws IOException {
    Map<NetworkInterface, List<Inet4Address>> ip4Interfaces = new HashMap<>();
    Map<NetworkInterface, List<Inet6Address>> ip6Interfaces = new HashMap<>();

    List<NetworkInterface> nifs = list(getNetworkInterfaces());
    for (NetworkInterface nif : nifs) {
        // ignore interfaces that are down
        if (!nif.isUp() || nif.isPointToPoint())
            continue;

        List<Inet4Address> ip4Addresses = new LinkedList<>();
        List<Inet6Address> ip6Addresses = new LinkedList<>();
        ip4Interfaces.put(nif, ip4Addresses);
        ip6Interfaces.put(nif, ip6Addresses);
        for (InetAddress addr : list(nif.getInetAddresses())) {
            if (addr instanceof Inet4Address)
                ip4Addresses.add((Inet4Address)addr);
            else if (addr instanceof Inet6Address)
                ip6Addresses.add((Inet6Address)addr);
        }
    }
    return new NetworkConfiguration(ip4Interfaces, ip6Interfaces);
}
 
Example #2
Source Project: mollyim-android   Author: mollyim   File: SmsDatabase.java    License: GNU General Public License v3.0 7 votes vote down vote up
public MessageRecord getCurrent() {
  return new SmsMessageRecord(id,
                              message.getMessageBody(),
                              message.getRecipient(),
                              message.getRecipient(),
                              1,
                              System.currentTimeMillis(),
                              System.currentTimeMillis(),
                              -1,
                              0,
                              message.isSecureMessage() ? MmsSmsColumns.Types.getOutgoingEncryptedMessageType() : MmsSmsColumns.Types.getOutgoingSmsMessageType(),
                              threadId,
                              0,
                              new LinkedList<>(),
                              message.getSubscriptionId(),
                              message.getExpiresIn(),
                              System.currentTimeMillis(),
                              0,
                              false,
                              Collections.emptyList(),
                              false);
}
 
Example #3
Source Project: lams   Author: lamsfoundation   File: VariantSupport.java    License: GNU General Public License v2.0 7 votes vote down vote up
/**
 * Writes a warning to {@code System.err} that a variant type is
 * unsupported by HPSF. Such a warning is written only once for each variant
 * type. Log messages can be turned on or off by
 *
 * @param ex The exception to log
 */
protected static void writeUnsupportedTypeMessage
    (final UnsupportedVariantTypeException ex) {
    if (isLogUnsupportedTypes())
    {
        if (unsupportedMessage == null) {
            unsupportedMessage = new LinkedList<Long>();
        }
        Long vt = Long.valueOf(ex.getVariantType());
        if (!unsupportedMessage.contains(vt))
        {
        	logger.log( POILogger.ERROR, ex.getMessage());
            unsupportedMessage.add(vt);
        }
    }
}
 
Example #4
Source Project: openAGV   Author: tcrct   File: StatisticsLogParser.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Parses the given log file and returns a list of records contained in it.
 *
 * @param inputFile The file to be parsed.
 * @return A list of records contained in the file.
 * @throws FileNotFoundException If the given file was not found.
 * @throws IOException If there was a problem reading the file.
 */
public static List<StatisticsRecord> parseLog(File inputFile)
    throws FileNotFoundException, IOException {
  requireNonNull(inputFile, "inputFile");

  List<StatisticsRecord> result = new LinkedList<>();
  try (BufferedReader inputReader = new BufferedReader(
      new InputStreamReader(new FileInputStream(inputFile), Charset.forName("UTF-8")))) {
    String inputLine = inputReader.readLine();
    while (inputLine != null) {
      StatisticsRecord record = StatisticsRecord.parseRecord(inputLine);
      if (record != null) {
        result.add(record);
      }
      inputLine = inputReader.readLine();
    }
  }
  catch (IOException exc) {
    LOG.warn("Exception parsing input file", exc);
    throw exc;
  }

  return result;
}
 
Example #5
Source Project: smarthome   Author: eclipse-archived   File: DeviceStatusManagerImpl.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private List<Device> getDetailedDevices() {
    List<Device> deviceList = new LinkedList<Device>();
    JsonObject result = connMan.getDigitalSTROMAPI().query2(connMan.getSessionToken(), GET_DETAILD_DEVICES);
    if (result != null && result.isJsonObject()) {
        if (result.getAsJsonObject().get(GeneralLibConstance.QUERY_BROADCAST_ZONE_STRING).isJsonObject()) {
            result = result.getAsJsonObject().get(GeneralLibConstance.QUERY_BROADCAST_ZONE_STRING)
                    .getAsJsonObject();
            for (Entry<String, JsonElement> entry : result.entrySet()) {
                if (!(entry.getKey().equals(JSONApiResponseKeysEnum.ZONE_ID.getKey())
                        && entry.getKey().equals(JSONApiResponseKeysEnum.NAME.getKey()))
                        && entry.getValue().isJsonObject()) {
                    deviceList.add(new DeviceImpl(entry.getValue().getAsJsonObject()));
                }
            }
        }
    }
    return deviceList;
}
 
Example #6
Source Project: rapidminer-studio   Author: rapidminer   File: Hypothesis.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
public LinkedList<Rule> generateRules(int ruleGenerationMode, Attribute label) {
	LinkedList<Rule> rules = new LinkedList<>();
	switch (ruleGenerationMode) {
		case POSITIVE_RULE:
			rules.add(getPositiveRule(label));
			break;
		case NEGATIVE_RULE:
			rules.add(getNegativeRule(label));
			break;
		case PREDICTION_RULE:
			rules.add(getPredictionRule(label));
			break;
		case POSITIVE_AND_NEGATIVE_RULES:
			rules.add(getPositiveRule(label));
			rules.add(getNegativeRule(label));
			break;
	}
	return rules;
}
 
Example #7
Source Project: sanshanblog   Author: SanShanYouJiu   File: UserRecommendService.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 完成用户推荐
 * @return
 */
public List<UserRecommendDO>  generateUsers(){
    List<UserRecommendDO> recommendUsers = new LinkedList<>();
    log.info("生成一次 推荐用户数据");

    //List<UserDO> users = userRepository.findAll();
    //for (int i = 0; i < users.size(); i++) {
    //    UserDO userDO = users.get(i);
    //    String username = userDO.getUsername();
    //    List<BlogVO> blogVOS = userBlogCacheService.getUserBlogs(username);
    //    for (int j = 0; j <blogVOS.size() ; j++) {
    //        Long id = blogVOS.get(i).getId();
    //        BlogRecommendDO blogRecommendDO = blogRecommendRepository.findOne(id);
    //        Double blogRate = blogRecommendDO.getRecommendRate();
    //    }
    //}
    return recommendUsers;
}
 
Example #8
Source Project: carbon-identity-framework   Author: wso2   File: SessionAuthHistory.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Undo/Remove entries upto and including the supplied entry from the history stack.
 * This can be done if the current authenticator decides it is FALLBACK.
 *
 * @return The last undone history element. Null if there is no matching entry.
 */
public AuthHistory undoUpto(AuthHistory historyElement) {
    LinkedList<AuthHistory> modifyingHistory = new LinkedList<>();
    AuthHistory matchedEntry = null;
    for (AuthHistory historyEntry : authenticationStepHistory) {
        if (historyEntry.equals(historyElement)) {
            matchedEntry = historyEntry;
            break;
        }
        modifyingHistory.add(historyEntry);
    }

    if (matchedEntry != null) {
        authenticationStepHistory = modifyingHistory;
    }
    return matchedEntry;
}
 
Example #9
Source Project: Neural-Network-Programming-with-Java-SecondEdition   Author: PacktPublishing   File: RandomNumberGenerator.java    License: MIT License 6 votes vote down vote up
public static int[] hashInt(int start,int end){
    LinkedList<Integer> ll = new LinkedList<>();
    ArrayList<Integer> al = new ArrayList<>();
    for(int i=start;i<=end;i++){
        ll.add(i);
    }
    int start0=0;
    for(int end0=end-start;end0>start0;end0--){
        int rnd = RandomNumberGenerator.GenerateIntBetween(start0, end0);
        int value = ll.get(rnd);
        ll.remove(rnd);
        al.add(value);
    }
    al.add(ll.get(0));
    ll.remove(0);
    return ArrayOperations.arrayListToIntVector(al);
}
 
Example #10
Source Project: howsun-javaee-framework   Author: howsun   File: JedisShartClient.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * @param args
 */
public static void main(String[] args) {
	List<JedisShardInfo> list = new LinkedList<JedisShardInfo>();
	JedisShardInfo jedisShardInfo1 = new JedisShardInfo(ip1, port);
	jedisShardInfo1.setPassword(JedisConstant.password);
	list.add(jedisShardInfo1);
	JedisShardInfo jedisShardInfo2 = new JedisShardInfo(ip2, port);
	jedisShardInfo2.setPassword(JedisConstant.password);
	list.add(jedisShardInfo2);
	ShardedJedisPool pool = new ShardedJedisPool(config, list);
	for (int i = 0; i < 2000; i++) {
		ShardedJedis jedis = pool.getResource();
		String key = "howsun_" + i;
		//jedis.set(key, UUID.randomUUID().toString());
		System.out.println(key + "\t" + jedis.get(key) + "\t" + jedis.toString());
		pool.returnResource(jedis);
	}
}
 
Example #11
Source Project: marathonv5   Author: jalian-systems   File: RFXMenuItem.java    License: Apache License 2.0 6 votes vote down vote up
private String getTagForMenu(MenuItem source) {
    LinkedList<MenuItem> menuItems = new LinkedList<>();
    while (source != null) {
        menuItems.addFirst(source);
        source = source.getParentMenu();
    }
    if (menuItems.getFirst() instanceof Menu) {
        if (menuItems.size() >= 2) {
            ownerNode = menuItems.get(1).getParentPopup().getOwnerNode();
            return isMenuBar(ownerNode) ? "#menu" : "#contextmenu";
        }
    } else {
        ownerNode = menuItems.getFirst().getParentPopup().getOwnerNode();
        return "#contextmenu";
    }
    return null;
}
 
Example #12
Source Project: uyuni   Author: uyuni-project   File: KickstartParser.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Constructor.
 * @param kickstartFileContentsIn Contents of the kickstart file.
 */
public KickstartParser(String kickstartFileContentsIn) {
    ksFileContents = kickstartFileContentsIn;

    optionLines = new LinkedList<String>();
    packageLines = new LinkedList<String>();
    preScriptLines = new LinkedList<String>();
    postScriptLines = new LinkedList<String>();

    String [] ksFileLines = ksFileContents.split("\\n");

    List<String> currentSectionLines = new LinkedList<String>();
    for (int i = 0; i < ksFileLines.length; i++) {
        String currentLine = ksFileLines[i];
        if (isNewSection(currentLine)) {
            storeSection(currentSectionLines);
            currentSectionLines = new LinkedList<String>();
        }

        currentSectionLines.add(currentLine);
    }
    storeSection(currentSectionLines);
}
 
Example #13
Source Project: netphony-topology   Author: telefonicaid   File: SimpleTEDB.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void notifyWavelengthReservationWLAN(LinkedList<Object> sourceVertexList,LinkedList<Object> targetVertexList,LinkedList<Integer> wlans, boolean bidirectional) 
{
	TEDBlock.lock();
	try {
		for (int i=0;i<sourceVertexList.size();++i){		
			IntraDomainEdge edge=networkGraph.getEdge(sourceVertexList.get(i), targetVertexList.get(i));
			edge.getTE_info().setWavelengthReserved(wlans.get(i));
			log.info("Reservo: "+sourceVertexList.get(i).toString() + "-"+ targetVertexList.get(i).toString() +" wavelength: "+wlans.get(i)+" bidirectional"+bidirectional);
			if (bidirectional == true){
				edge=networkGraph.getEdge(targetVertexList.get(i), sourceVertexList.get(i));
				edge.getTE_info().setWavelengthReserved(wlans.get(i));
				//log.info(""+edge.toString());
			}
		}
	}finally{
		TEDBlock.unlock();
	}
	for (int i=0;i<registeredAlgorithms.size();++i){
		registeredAlgorithms.get(i).notifyWavelengthReservation(sourceVertexList, targetVertexList, wlans.get(i));
		if (bidirectional == true){
			registeredAlgorithms.get(i).notifyWavelengthReservation(targetVertexList, sourceVertexList, wlans.get(i));
		}
	}

}
 
Example #14
Source Project: pulsar   Author: apache   File: SinkConfigUtils.java    License: Apache License 2.0 6 votes vote down vote up
private static Collection<String> collectAllInputTopics(SinkConfig sinkConfig) {
    List<String> retval = new LinkedList<>();
    if (sinkConfig.getInputs() != null) {
        retval.addAll(sinkConfig.getInputs());
    }
    if (sinkConfig.getTopicToSerdeClassName() != null) {
        retval.addAll(sinkConfig.getTopicToSerdeClassName().keySet());
    }
    if (sinkConfig.getTopicsPattern() != null) {
        retval.add(sinkConfig.getTopicsPattern());
    }
    if (sinkConfig.getTopicToSchemaType() != null) {
        retval.addAll(sinkConfig.getTopicToSchemaType().keySet());
    }
    if (sinkConfig.getInputSpecs() != null) {
        retval.addAll(sinkConfig.getInputSpecs().keySet());
    }
    return retval;
}
 
Example #15
Source Project: elements-of-programming-interviews   Author: gardncl   File: ComputeExteriorTest.java    License: MIT License 6 votes vote down vote up
@Test//a b c d e h m n p o i
public void exteriorBinaryTree3() throws Exception {
    tree = BinaryTreeUtil.getFigureTenDotOne();
    expected = new LinkedList<>(
            Arrays.asList(
                    tree,
                    tree.left,
                    tree.left.left,
                    tree.left.left.left,
                    tree.left.left.right,
                    tree.left.right.right.left,
                    tree.right.left.right.left.right,
                    tree.right.left.right.right,
                    tree.right.right.right,
                    tree.right.right,
                    tree.right)
    );

    test(expected, tree);
}
 
Example #16
Source Project: netbeans   Author: apache   File: FindDuplicatesRefactoringPlugin.java    License: Apache License 2.0 6 votes vote down vote up
@Messages("WARN_HasQueries=The selected configuration contains inspections that do not provide any transformations. " +
          "No diff will be provided for code detected by such inspections. Use Source/Inspect... to perform code analysis.")
private List<MessageImpl> performSearchForPattern(final RefactoringElementsBag refactoringElements) {
    ProgressHandleWrapper w = new ProgressHandleWrapper(this, 10, 90);
    Iterable<? extends HintDescription> queries = filterQueries(refactoring.getPattern(), true);
    BatchResult candidates = BatchSearch.findOccurrences(queries, refactoring.getScope(), w, /*XXX:*/HintsSettings.getGlobalSettings());
    List<MessageImpl> problems = new LinkedList<MessageImpl>(candidates.problems);

    if (queries.iterator().hasNext()) {
        problems.add(new MessageImpl(MessageKind.WARNING, Bundle.WARN_HasQueries()));
    }
    
    prepareElements(candidates, w, refactoringElements, refactoring.isVerify(), problems);

    w.finish();

    return problems;
 }
 
Example #17
Source Project: arcusplatform   Author: arcus-smart-home   File: TestAlarmSubsystemCallTree.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testCallTree() {		
	List<Map<String, Object>> list = new LinkedList<Map<String,Object>>();
	CallTreeEntry entry1 = createCallTreeEntry(owner, true);
	CallTreeEntry entry2 = createCallTreeEntry(person1, true);
	CallTreeEntry entry3 = createCallTreeEntry(person2, true);
	list.addAll(ImmutableList.<Map<String,Object>>of(entry1.toMap(), entry2.toMap(), entry3.toMap()));
	replay();
		
					
	//1. owner first and enabled
	doSetAttributeForOkScenario(list, ImmutableList.<CallTreeEntry> of(entry1, entry2, entry3));
	
	
	//2. owner 2nd and enabled, OK, should fail
	Map<String, Object> removed = list.remove(0);
	list.add(1, removed);
	doSetAttributeForFailedScenario(list, "Should get an exception for account owner not first");
	
	//3. owner first and disabled, fail
	entry1.setEnabled(false);
	removed = list.remove(1);
	list.add(0, entry1.toMap());
	doSetAttributeForFailedScenario(list, "Should get an exception for owner first and disabled");		
			
}
 
Example #18
Source Project: hottub   Author: dsrg-uoft   File: ListDefaults.java    License: GNU General Public License v2.0 6 votes vote down vote up
@DataProvider(name="listProvider", parallel=true)
public static Object[][] listCases() {
    final List<Object[]> cases = new LinkedList<>();
    cases.add(new Object[] { Collections.emptyList() });
    cases.add(new Object[] { new ArrayList<>() });
    cases.add(new Object[] { new LinkedList<>() });
    cases.add(new Object[] { new Vector<>() });
    cases.add(new Object[] { new Stack<>() });
    cases.add(new Object[] { new CopyOnWriteArrayList<>() });
    cases.add(new Object[] { Arrays.asList() });

    List<Integer> l = Arrays.asList(42);
    cases.add(new Object[] { new ArrayList<>(l) });
    cases.add(new Object[] { new LinkedList<>(l) });
    cases.add(new Object[] { new Vector<>(l) });
    Stack<Integer> s = new Stack<>(); s.addAll(l);
    cases.add(new Object[]{s});
    cases.add(new Object[] { new CopyOnWriteArrayList<>(l) });
    cases.add(new Object[] { l });
    return cases.toArray(new Object[0][cases.size()]);
}
 
Example #19
Source Project: arcusplatform   Author: arcus-smart-home   File: HubRegistrationDAOImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected List<Object> getValues(HubRegistration entity) {	
	List<Object> values = new LinkedList<Object>();		
	  //Note this needs to be same order as defined in COLUMN_ORDER
      values.add(entity.getLastConnected());
      values.add(entity.getState()!=null?entity.getState().name():null);
      values.add(entity.getUpgradeRequestTime());
      values.add(entity.getFirmwareVersion());
      values.add(entity.getTargetVersion());
      values.add(entity.getUpgradeErrorCode());
      values.add(entity.getUpgradeErrorMessage());
      values.add(entity.getDownloadProgress());
      values.add(entity.getUpgradeErrorTime());
      log.trace("HubRegistration:Values = [{}]", values );
      return values;
}
 
Example #20
Source Project: netbeans   Author: apache   File: IncludeInCommitAction.java    License: Apache License 2.0 5 votes vote down vote up
private static List<String> filterRoots (File[] roots) {
    List<String> toInclude = new LinkedList<String>();
    GitModuleConfig config = GitModuleConfig.getDefault();
    for (File root : roots) {
        String path = root.getAbsolutePath();
        if (config.isExcludedFromCommit(path)) {
            toInclude.add(path);
        }
    }
    return toInclude;
}
 
Example #21
@Override
public JPopupMenu getPopupMenu() {
	JPopupMenu menu = new JPopupMenu();

	List<JMenuItem> serverItems = new LinkedList<>();
	// add server items
	for (String serverName : remoteControllers.keySet()) {

		ConfigurableController controller = remoteControllers.get(serverName);

		// if the connection to the server is established
		if (controller.getModel().getSource().isConnected()) {

			JMenuItem newItem = new JMenuItem(I18N.getGUILabel("configurable_dialog.refresh_config.server.label",
					serverName));
			newItem.setActionCommand(serverName);
			newItem.addActionListener(actionListener);
			serverItems.add(newItem);
		}
	}

	// add items to menu
	if (serverItems.size() >= 2) {
		// add the refresh all connections part only if there are at
		// least
		// two connected servers
		menu.add(allConnectionsItem);
		menu.addSeparator();
	}

	for (JMenuItem item : serverItems) {
		menu.add(item);
	}
	return menu;
}
 
Example #22
Source Project: gate-core   Author: GateNLP   File: CompoundFileWriter.java    License: GNU Lesser General Public License v3.0 5 votes vote down vote up
/** Create the compound stream in the specified file. The file name is the
 *  entire name (no extensions are added).
 */
public CompoundFileWriter(Directory dir, String name) {
    if (dir == null)
        throw new IllegalArgumentException("Missing directory");
    if (name == null)
        throw new IllegalArgumentException("Missing name");

    directory = dir;
    fileName = name;
    ids = new HashSet();
    entries = new LinkedList();
}
 
Example #23
Source Project: jdk8u_jdk   Author: JetBrains   File: Introspector.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the list of "getter" methods for the given class. The list
 * is ordered so that isXXX methods appear before getXXX methods - this
 * is for compatibility with the JavaBeans Introspector.
 */
static List<Method> getReadMethods(Class<?> clazz) {
    // return cached result if available
    List<Method> cachedResult = getCachedMethods(clazz);
    if (cachedResult != null)
        return cachedResult;

    // get list of public methods, filtering out methods that have
    // been overridden to return a more specific type.
    List<Method> methods =
        StandardMBeanIntrospector.getInstance().getMethods(clazz);
    methods = MBeanAnalyzer.eliminateCovariantMethods(methods);

    // filter out the non-getter methods
    List<Method> result = new LinkedList<Method>();
    for (Method m: methods) {
        if (isReadMethod(m)) {
            // favor isXXX over getXXX
            if (m.getName().startsWith(IS_METHOD_PREFIX)) {
                result.add(0, m);
            } else {
                result.add(m);
            }
        }
    }

    // add result to cache
    cache.put(clazz, new SoftReference<List<Method>>(result));

    return result;
}
 
Example #24
Source Project: spring-analysis-note   Author: Vip-Augus   File: UrlTagTests.java    License: MIT License 5 votes vote down vote up
@Test
public void createQueryStringOneParamForExsistingQueryString() throws JspException {
	List<Param> params = new LinkedList<>();
	Set<String> usedParams = new HashSet<>();

	Param param = new Param();
	param.setName("name");
	param.setValue("value");
	params.add(param);

	String queryString = tag.createQueryString(params, usedParams, false);
	assertEquals("&name=value", queryString);
}
 
Example #25
Source Project: SubServers-2   Author: ME1312   File: PacketOutExRunEvent.java    License: Apache License 2.0 5 votes vote down vote up
private void broadcast(Object self, PacketOutExRunEvent packet) {
    if (plugin.subdata != null) {
        List<SubDataClient> clients = new LinkedList<SubDataClient>();
        clients.addAll(plugin.subdata.getClients().values());
        for (SubDataClient client : clients) {
            if (client.getHandler() == null || client.getHandler() != self) { // Don't send events about yourself to yourself
                if (client.getHandler() == null || client.getHandler().getSubData()[0] == client) { // Don't send events over subchannels
                    client.sendPacket(packet);
                }
            }
        }
    }
}
 
Example #26
Source Project: shardingsphere   Author: apache   File: EncryptMetaDataDecorator.java    License: Apache License 2.0 5 votes vote down vote up
private Collection<ColumnMetaData> getEncryptColumnMetaDataList(final String tableName, final Collection<ColumnMetaData> originalColumnMetaDataList, final EncryptRule encryptRule) {
    Collection<ColumnMetaData> result = new LinkedList<>();
    Collection<String> derivedColumns = encryptRule.getAssistedQueryAndPlainColumns(tableName);
    for (ColumnMetaData each : originalColumnMetaDataList) {
        if (!derivedColumns.contains(each.getName())) {
            result.add(getEncryptColumnMetaData(tableName, each, encryptRule));
        }
    }
    return result;
}
 
Example #27
Source Project: hbase   Author: apache   File: TestPerformanceEvaluation.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void testParseOptsNoThreads() {
  Queue<String> opts = new LinkedList<>();
  String cmdName = "sequentialWrite";
  try {
    PerformanceEvaluation.parseOpts(opts);
  } catch (IllegalArgumentException e) {
    System.out.println(e.getMessage());
    assertEquals("Command " + cmdName + " does not have threads number", e.getMessage());
    assertTrue(e.getCause() instanceof NoSuchElementException);
  }
}
 
Example #28
Source Project: Bats   Author: lealone   File: Node.java    License: Apache License 2.0 5 votes vote down vote up
public Node(OPERATOR operator, OperatorContext context)
{
  this.operator = operator;
  this.context = context;
  executorService = Executors.newSingleThreadExecutor();
  taskQueue = new LinkedList<>();

  outputs = new HashMap<>();

  descriptor = new PortMappingDescriptor();
  Operators.describe(operator, descriptor);

  endWindowDequeueTimes = new HashMap<>();
  tmb = ManagementFactory.getThreadMXBean();
  commandResponse = new LinkedBlockingQueue<>();

  metricFields = Lists.newArrayList();
  for (Field field : ReflectionUtils.getDeclaredFieldsIncludingInherited(operator.getClass())) {
    if (field.isAnnotationPresent(AutoMetric.class)) {
      metricFields.add(field);
      field.setAccessible(true);
    }
  }

  metricMethods = Maps.newHashMap();
  try {
    for (PropertyDescriptor pd : Introspector.getBeanInfo(operator.getClass()).getPropertyDescriptors()) {
      Method readMethod = pd.getReadMethod();
      if (readMethod != null) {
        AutoMetric rfa = readMethod.getAnnotation(AutoMetric.class);
        if (rfa != null) {
          metricMethods.put(pd.getName(), readMethod);
        }
      }
    }
  } catch (IntrospectionException e) {
    throw new RuntimeException("introspecting {}", e);
  }
}
 
Example #29
Source Project: everrest   Author: codenvy   File: WSClient.java    License: Eclipse Public License 2.0 5 votes vote down vote up
public Builder(URI serverUri) {
    if (serverUri == null) {
        throw new IllegalArgumentException("Connection URI may not be null");
    }
    this.serverUri = serverUri;
    listeners = new LinkedList<>();
    channels = new LinkedList<>();
    final List<String> channelsFromUri = parseQueryString(serverUri.getRawQuery(), true).get("channel");
    if (channelsFromUri != null) {
        channels.addAll(channelsFromUri);
    }
}
 
Example #30
Source Project: skywalking   Author: apache   File: LinkedArrayBenchmark.java    License: Apache License 2.0 5 votes vote down vote up
@Benchmark
public void testReusedLinked200K() {
    LinkedList<SampleData> list = new LinkedList<SampleData>();
    for (int times = 0; times < 1000; times++) {
        for (int pos = 0; pos < 200000; pos++) {
            list.add(new SampleData());
        }
        list.clear();
    }
}