当前位置: 首页>>代码示例>>Java>>正文


Java Utils.getInt方法代码示例

本文整理汇总了Java中backtype.storm.utils.Utils.getInt方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.getInt方法的具体用法?Java Utils.getInt怎么用?Java Utils.getInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在backtype.storm.utils.Utils的用法示例。


在下文中一共展示了Utils.getInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: maxTopologyMessageTimeout

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public int maxTopologyMessageTimeout() {
	Integer max = Utils.getInt(_stormConf
			.get(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS));
	for (String spout : getRawTopology().get_spouts().keySet()) {
		ComponentCommon common = getComponentCommon(spout);
		String jsonConf = common.get_json_conf();
		if (jsonConf != null) {
			Map conf = (Map) Utils.from_json(jsonConf);
			Object comp = conf.get(Config.TOPOLOGY_MESSAGE_TIMEOUT_SECS);
			if (comp != null) {
				max = Math.max(Utils.getInt(comp), max);
			}
		}
	}
	return max;
}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:17,代码来源:GeneralTopologyContext.java

示例2: open

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void open(Map conf, TopologyContext context,
		SpoutOutputCollector collector) {
	_rand = new Random(Utils.secureRandomLong());
	_state = TransactionalState.newCoordinatorState(conf,
			(String) conf.get(Config.TOPOLOGY_TRANSACTIONAL_ID),
			_spout.getComponentConfiguration());
	_coordinatorState = new RotatingTransactionalState(_state, META_DIR,
			true);
	_collector = collector;
	_coordinator = _spout.getCoordinator(conf, context);
	_currTransaction = getStoredCurrTransaction(_state);
	Object active = conf.get(Config.TOPOLOGY_MAX_SPOUT_PENDING);
	if (active == null) {
		_maxTransactionActive = 1;
	} else {
		_maxTransactionActive = Utils.getInt(active);
	}
	_initializer = new StateInitializer();
}
 
开发者ID:greeenSY,项目名称:Tstream,代码行数:21,代码来源:TransactionalSpoutCoordinator.java

示例3: MasterServer

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
private MasterServer(@SuppressWarnings("rawtypes") Map storm_conf,
        StormMasterServerHandler handler) {
    super(storm_conf, 
            new Processor<StormMaster.Iface>(handler), 
            Utils.getInt(storm_conf.get(Config.MASTER_THRIFT_PORT)));
    try {
        _handler = handler;
        _handler.init(this);
        
        LOG.info("launch nimbus");
        _handler.startNimbus();

        LOG.info("launch ui");
        _handler.startUI();

        int numSupervisors =
                Utils.getInt(storm_conf.get(Config.MASTER_NUM_SUPERVISORS));
        LOG.info("launch " + numSupervisors + " supervisors");
        _handler.addSupervisors(numSupervisors);
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:24,代码来源:MasterServer.java

示例4: getConfiguredClient

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public static MasterClient getConfiguredClient(Map conf) throws Exception {
		
		try {
            String masterHost = (String) conf.get(Config.MASTER_HOST);
//            String zookeeper = conf.get(Config.)
            LOG.info("masterHost is:" + masterHost);
            
            int masterPort = Utils.getInt(conf.get(Config.MASTER_THRIFT_PORT));
            LOG.info("masterPort is" + masterPort);
            System.out.println("masterPort is" + masterPort);
            try {
            	Integer timeout = Utils.getInt(conf.get(Config.MASTER_TIMEOUT_SECS));
            	return new MasterClient(conf, masterHost, masterPort, timeout);
            } catch (IllegalArgumentException e) {
            	return new MasterClient(conf, masterHost, masterPort, null);
            }
            
        } catch (TTransportException ex) {
            throw new RuntimeException(ex);
        }
	}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:22,代码来源:MasterClient.java

示例5: NettyClientAsync

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@SuppressWarnings("rawtypes")
NettyClientAsync(Map storm_conf, ChannelFactory factory, ScheduledExecutorService scheduler, String host, int port, ReconnectRunnable reconnector) {
    super(storm_conf, factory, scheduler, host, port, reconnector);

    BATCH_THREASHOLD_WARN = ConfigExtension.getNettyBufferThresholdSize(storm_conf);
    blockSend = isBlockSend(storm_conf);
    directlySend = isDirectSend(storm_conf);

    flush_later = new AtomicBoolean(false);
    flushCheckInterval = Utils.getInt(storm_conf.get(Config.STORM_NETTY_FLUSH_CHECK_INTERVAL_MS), 10);

    Runnable flusher = new Runnable() {
        @Override
        public void run() {
            flush();
        }
    };
    long initialDelay = Math.min(1000, max_sleep_ms * max_retries);
    scheduler.scheduleAtFixedRate(flusher, initialDelay, flushCheckInterval, TimeUnit.MILLISECONDS);

    clientChannelFactory = factory;

    start();
    LOG.info(this.toString());
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:26,代码来源:NettyClientAsync.java

示例6: open

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void open(Map conf, TopologyContext context,
		SpoutOutputCollector collector) {
	_collector = collector;
	if (_local_drpc_id == null) {
		int numTasks = context.getComponentTasks(
				context.getThisComponentId()).size();
		int index = context.getThisTaskIndex();

		int port = Utils.getInt(conf.get(Config.DRPC_INVOCATIONS_PORT));
		List<String> servers = (List<String>) conf.get(Config.DRPC_SERVERS);
		if (servers == null || servers.isEmpty()) {
			throw new RuntimeException(
					"No DRPC servers configured for topology");
		}
		if (numTasks < servers.size()) {
			for (String s : servers) {
				_clients.add(new DRPCInvocationsClient(s, port));
			}
		} else {
			int i = index % servers.size();
			_clients.add(new DRPCInvocationsClient(servers.get(i), port));
		}
	}

}
 
开发者ID:greeenSY,项目名称:Tstream,代码行数:27,代码来源:DRPCSpout.java

示例7: startDispatchThread

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
private AsyncLoopThread startDispatchThread() {
	Map stormConf = workerData.getStormConf();

	int queue_size = Utils.getInt(
			stormConf.get(Config.TOPOLOGY_TRANSFER_BUFFER_SIZE), 1024);
	WaitStrategy waitStrategy = (WaitStrategy) Utils
			.newInstance((String) stormConf
					.get(Config.TOPOLOGY_DISRUPTOR_WAIT_STRATEGY));
	DisruptorQueue recvQueue = DisruptorQueue.mkInstance("Dispatch", ProducerType.MULTI,
			queue_size, waitStrategy);
	// stop  consumerStarted
	//recvQueue.consumerStarted();

	IContext context = workerData.getContext();
	String topologyId = workerData.getTopologyId();

	IConnection recvConnection = context.bind(topologyId,
			workerData.getPort());
	recvConnection.registerQueue(recvQueue);

	RunnableCallback recvDispather = new VirtualPortDispatch(workerData,
			recvConnection, recvQueue);

	AsyncLoopThread vthread = new AsyncLoopThread(recvDispather, false,
			Thread.MAX_PRIORITY, false);

	return vthread;
}
 
开发者ID:greeenSY,项目名称:Tstream,代码行数:29,代码来源:Worker.java

示例8: Emitter

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public Emitter(Map conf) {
	Object c = conf.get(Config.TOPOLOGY_MAX_SPOUT_PENDING);
	if (c == null)
		_maxSpoutPending = 1;
	else
		_maxSpoutPending = Utils.getInt(c);
}
 
开发者ID:greeenSY,项目名称:Tstream,代码行数:8,代码来源:OpaqueMemoryTransactionalSpout.java

示例9: complete

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void complete(ReturnResultsState state, TridentCollector collector) {
    // only one of the multireducers will receive the tuples
    if(state.returnInfo!=null) {
        String result = Utils.to_json(state.results);
        Map retMap = (Map) Utils.from_json(state.returnInfo);
        final String host = (String) retMap.get("host");
        final int port = Utils.getInt(retMap.get("port"));
        String id = (String) retMap.get("id");
        DistributedRPCInvocations.Iface client;
        if(local) {
            client = (DistributedRPCInvocations.Iface) ServiceRegistry.getService(host);
        } else {
List server = new ArrayList() {/**
	 * 
	 */
	private static final long serialVersionUID = -2178334393663496091L;

{
                add(host);
                add(port);
            }};

            if(!_clients.containsKey(server)) {
                _clients.put(server, new DRPCInvocationsClient(host, port));
            }
            client = _clients.get(server);
        }

        try {
            client.result(id, result);
        } catch(TException e) {
            collector.reportError(e);
        }
    }
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:37,代码来源:ReturnResultsReducer.java

示例10: submitJar

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public static String submitJar(Map conf, String localJar, String uploadLocation, NimbusClient client) {
    if (localJar == null) {
        throw new RuntimeException("Must submit topologies using the 'storm' client script so that StormSubmitter knows which jar to upload.");
    }

    try {

        LOG.info("Uploading topology jar " + localJar + " to assigned location: " + uploadLocation);
        int bufferSize = 512 * 1024;
        Object maxBufSizeObject = conf.get(Config.NIMBUS_THRIFT_MAX_BUFFER_SIZE);
        if (maxBufSizeObject != null) {
            bufferSize = Utils.getInt(maxBufSizeObject) / 2;
        }

        BufferFileInputStream is = new BufferFileInputStream(localJar, bufferSize);
        while (true) {
            byte[] toSubmit = is.read();
            if (toSubmit.length == 0)
                break;
            client.getClient().uploadChunk(uploadLocation, ByteBuffer.wrap(toSubmit));
        }
        client.getClient().finishFileUpload(uploadLocation);
        LOG.info("Successfully uploaded topology jar to assigned location: " + uploadLocation);
        return uploadLocation;
    } catch (Exception e) {
        throw new RuntimeException(e);
    } finally {

    }
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:31,代码来源:StormSubmitter.java

示例11: complete

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void complete(ReturnResultsState state, TridentCollector collector) {
    // only one of the multireducers will receive the tuples
    if(state.returnInfo!=null) {
        String result = Utils.to_json(state.results);
        Map retMap = (Map) Utils.from_json(state.returnInfo);
        final String host = (String) retMap.get("host");
        final int port = Utils.getInt(retMap.get("port"));
        String id = (String) retMap.get("id");
        DistributedRPCInvocations.Iface client;
        if(local) {
            client = (DistributedRPCInvocations.Iface) ServiceRegistry.getService(host);
        } else {
            List server = new ArrayList() {{
                add(host);
                add(port);
            }};

            if(!_clients.containsKey(server)) {
                _clients.put(server, new DRPCInvocationsClient(host, port));
            }
            client = _clients.get(server);
        }

        try {
            client.result(id, result);
        } catch(TException e) {
            collector.reportError(e);
        }
    }
}
 
开发者ID:greeenSY,项目名称:Tstream,代码行数:32,代码来源:ReturnResultsReducer.java

示例12: Emitter

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public Emitter(Map conf) {
    Object c = conf.get(Config.TOPOLOGY_MAX_SPOUT_PENDING);
    if (c == null)
        _maxSpoutPending = 1;
    else
        _maxSpoutPending = Utils.getInt(c);
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:8,代码来源:MemoryTransactionalSpout.java

示例13: StormAMRMClient

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
public StormAMRMClient(ApplicationAttemptId appAttemptID, @SuppressWarnings("rawtypes") Map storm_conf,
		YarnConfiguration hadoopConf) {
	this.appAttemptId = appAttemptID;
    this.storm_conf = storm_conf;
    this.hadoopConf = hadoopConf;
    Integer pri = Utils.getInt(storm_conf.get(Config.MASTER_CONTAINER_PRIORITY));
    this.DEFAULT_PRIORITY.setPriority(pri);
    this.containers = new TreeSet<Container>();
    numSupervisors = new AtomicInteger(0);

    // start am nm client
    nmClient = (NMClientImpl) NMClient.createNMClient();
    nmClient.init(hadoopConf);
    nmClient.start();
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:16,代码来源:StormAMRMClient.java

示例14: open

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@Override
public void open(Map conf, TopologyContext context, SpoutOutputCollector collector) {
    _collector = collector;
    if (_local_drpc_id == null) {
        _backround = new ExtendedThreadPoolExecutor(0, Integer.MAX_VALUE, 60L, TimeUnit.SECONDS, new SynchronousQueue<Runnable>());
        _futures = new LinkedList<Future<Void>>();

        int numTasks = context.getComponentTasks(context.getThisComponentId()).size();
        int index = context.getThisTaskIndex();

        int port = Utils.getInt(conf.get(Config.DRPC_INVOCATIONS_PORT));
        List<String> servers = NetWorkUtils.host2Ip((List<String>) conf.get(Config.DRPC_SERVERS));

        if (servers == null || servers.isEmpty()) {
            throw new RuntimeException("No DRPC servers configured for topology");
        }

        if (numTasks < servers.size()) {
            for (String s : servers) {
                _futures.add(_backround.submit(new Adder(s, port, conf)));
            }
        } else {
            int i = index % servers.size();
            _futures.add(_backround.submit(new Adder(servers.get(i), port, conf)));
        }
    }

}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:29,代码来源:DRPCSpout.java

示例15: main

import backtype.storm.utils.Utils; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static void main(String[] args) throws Exception {
    LOG.info("Starting the AM!!!!");

    Options opts = new Options();
    opts.addOption("app_attempt_id", true, "App Attempt ID. Not to be used " +
            "unless for testing purposes");

    CommandLine cl = new GnuParser().parse(opts, args);

    ApplicationAttemptId appAttemptID;
    Map<String, String> envs = System.getenv();
    if (cl.hasOption("app_attempt_id")) {
      String appIdStr = cl.getOptionValue("app_attempt_id", "");
      appAttemptID = ConverterUtils.toApplicationAttemptId(appIdStr);
    } else if (envs.containsKey(ApplicationConstants.Environment.CONTAINER_ID.name())) {
      ContainerId containerId = ConverterUtils.toContainerId(envs
              .get(ApplicationConstants.Environment.CONTAINER_ID.name()));
      appAttemptID = containerId.getApplicationAttemptId();
      LOG.info("appAttemptID from env:" + appAttemptID.toString());
    } else {
      LOG.error("appAttemptID is not specified for storm master");
      throw new Exception("appAttemptID is not specified for storm master");
    }

    @SuppressWarnings("rawtypes")
    Map storm_conf = Config.readJStormConfig(null);
    Util.rmNulls(storm_conf);

    YarnConfiguration hadoopConf = new YarnConfiguration();

    final String host = InetAddress.getLocalHost().getHostName();
    storm_conf.put("nimbus.host", host);

    StormAMRMClient rmClient =
            new StormAMRMClient(appAttemptID, storm_conf, hadoopConf);
    rmClient.init(hadoopConf);
    rmClient.start();

    BlockingQueue<Container> launcherQueue = new LinkedBlockingQueue<Container>();

    MasterServer server = new MasterServer(storm_conf, rmClient);
    try {
        final int port = Utils.getInt(storm_conf.get(Config.MASTER_THRIFT_PORT));
        final String target = host + ":" + port;
        InetSocketAddress addr = NetUtils.createSocketAddr(target);
        RegisterApplicationMasterResponse resp =
                rmClient.registerApplicationMaster(addr.getHostName(), port, null);
        LOG.info("Got a registration response "+resp);
        LOG.info("Max Capability "+resp.getMaximumResourceCapability());
        rmClient.setMaxResource(resp.getMaximumResourceCapability());
        LOG.info("Starting HB thread");
        server.initAndStartHeartbeat(rmClient, launcherQueue,
                (Integer) storm_conf
                .get(Config.MASTER_HEARTBEAT_INTERVAL_MILLIS));
        LOG.info("Starting launcher");
        initAndStartLauncher(rmClient, launcherQueue);
        rmClient.startAllSupervisors();
        LOG.info("Starting Master Thrift Server");
        server.serve();
        LOG.info("StormAMRMClient::unregisterApplicationMaster");
        rmClient.unregisterApplicationMaster(FinalApplicationStatus.SUCCEEDED,
                "AllDone", null);
    } finally {
        if (server.isServing()) {
            LOG.info("Stop Master Thrift Server");
            server.stop();
        }
        LOG.info("Stop RM client");
        rmClient.stop();
    }
    System.exit(0);
}
 
开发者ID:kkllwww007,项目名称:jstrom,代码行数:74,代码来源:MasterServer.java


注:本文中的backtype.storm.utils.Utils.getInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。