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


Java TException类代码示例

本文整理汇总了Java中org.apache.thrift7.TException的典型用法代码示例。如果您正苦于以下问题:Java TException类的具体用法?Java TException怎么用?Java TException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: ack

import org.apache.thrift7.TException; //导入依赖的package包/类
@Override
public void ack(Object msgId) {
	final KestrelSourceId sourceId = (KestrelSourceId) msgId;
	final KestrelClientInfo info = _kestrels.get(sourceId.index);

	// if the transaction didn't exist, it just returns false. so this code
	// works
	// even if client gets blacklisted, disconnects, and kestrel puts the
	// item
	// back on the queue
	try {
		if (info.client != null) {
			final HashSet<Long> xids = new HashSet<Long>();
			xids.add(sourceId.id);
			info.client.confirm(_queueName, xids);
		}
	} catch (final TException e) {
		blacklist(info, e);
	}
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:21,代码来源:KestrelThriftSpout.java

示例2: setStormConf

import org.apache.thrift7.TException; //导入依赖的package包/类
@Override
public void setStormConf(String storm_conf) throws TException {
	LOG.info("setting configuration...");

       // stop processes
       stopSupervisors();
       stopUI();
       stopNimbus();

       Object json = JSONValue.parse(storm_conf);
       Map<?, ?> new_conf = (Map<?, ?>)json;
       _storm_conf.putAll(new_conf);
       Util.rmNulls(_storm_conf);
       setStormHostConf();
       
       // start processes
       startNimbus();
       startUI();
       startSupervisors();
}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:21,代码来源:StormMasterServerHandler.java

示例3: downloadCodeFromMaster

import org.apache.thrift7.TException; //导入依赖的package包/类
private void downloadCodeFromMaster(Assignment assignment, String topologyId)
		throws IOException, TException {
	try {
		String localRoot = StormConfig.masterStormdistRoot(data.getConf(),
				topologyId);
		String tmpDir = StormConfig.masterInbox(data.getConf()) + "/"
				+ UUID.randomUUID().toString();
		String masterCodeDir = assignment.getMasterCodeDir();
		JStormServerUtils.downloadCodeFromMaster(data.getConf(), tmpDir,
				masterCodeDir, topologyId, false);

		FileUtils.moveDirectory(new File(tmpDir), new File(localRoot));
	} catch (TException e) {
		// 
		LOG.error(e + " downloadStormCode failed " + "topologyId:"
				+ topologyId + "masterCodeDir:"
				+ assignment.getMasterCodeDir());
		throw e;
	}
	LOG.info("Finished downloading code for topology id " + topologyId
			+ " from " + assignment.getMasterCodeDir());
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:23,代码来源:FollowerRunnable.java

示例4: finishFileUpload

import org.apache.thrift7.TException; //导入依赖的package包/类
@Override
public void finishFileUpload(String location) throws TException {

	TimeCacheMap<Object, Object> uploaders = data.getUploaders();
	Object obj = uploaders.get(location);
	if (obj == null) {
		throw new TException(
				"File for that location does not exist (or timed out)");
	}
	try {
		if (obj instanceof WritableByteChannel) {
			WritableByteChannel channel = (WritableByteChannel) obj;
			channel.close();
			uploaders.remove(location);
			LOG.info("Finished uploading file from client: " + location);
		} else {
			throw new TException("Object isn't WritableByteChannel for "
					+ location);
		}
	} catch (IOException e) {
		LOG.error(" WritableByteChannel close failed when finishFileUpload "
				+ location);
	}

}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:26,代码来源:ServiceHandler.java

示例5: getTopology

import org.apache.thrift7.TException; //导入依赖的package包/类
/**
 * get StormTopology throw deserialize local files
 * 
 * @param id
 *            String: topology id
 * @return StormTopology
 */
@Override
public StormTopology getTopology(String id) throws NotAliveException,
		TException {
	StormTopology topology = null;
	try {
		StormTopology stormtopology = StormConfig
				.read_nimbus_topology_code(conf, id);
		if (stormtopology == null) {
			throw new TException("topology:" + id + "is null");
		}

		Map<Object, Object> topologyConf = StormConfig
				.read_nimbus_topology_conf(conf, id);

		topology = Common.system_topology(topologyConf, stormtopology);
	} catch (Exception e) {
		LOG.error("Failed to get topology " + id + ",", e);
		throw new TException("Failed to get system_topology");
	}
	return topology;
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:29,代码来源:ServiceHandler.java

示例6: metricMonitor

import org.apache.thrift7.TException; //导入依赖的package包/类
@Override
public void metricMonitor(String topologyName, MonitorOptions options) throws NotAliveException, 
        TException {
	boolean isEnable = options.is_isEnable();
	StormClusterState clusterState = data.getStormClusterState();
	
	try {
	    String topologyId = Cluster.get_topology_id(clusterState, topologyName);
	    if (null != topologyId) {
		    NimbusUtils.updateMetricMonitorStatus(clusterState, topologyId, isEnable);
	    } else {
		    throw new NotAliveException("Failed to update metricsMonitor status as " + topologyName + " is not alive");
	    }
	} catch(Exception e) {
		String errMsg = "Failed to update metricsMonitor " + topologyName;
		LOG.error(errMsg, e);
		throw new TException(e);
	}
	
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:21,代码来源:ServiceHandler.java

示例7: downloadDistributeStormCode

import org.apache.thrift7.TException; //导入依赖的package包/类
/**
 * Don't need synchronize, due to EventManager will execute serially
 * 
 * @param conf
 * @param topologyId
 * @param masterCodeDir
 * @throws IOException
 * @throws TException
 */
private void downloadDistributeStormCode(Map conf, String topologyId,
		String masterCodeDir) throws IOException, TException {

	// STORM_LOCAL_DIR/supervisor/tmp/(UUID)
	String tmproot = StormConfig.supervisorTmpDir(conf) + File.separator
			+ UUID.randomUUID().toString();

	// STORM_LOCAL_DIR/supervisor/stormdist/topologyId
	String stormroot = StormConfig.supervisor_stormdist_root(conf,
			topologyId);

	JStormServerUtils.downloadCodeFromMaster(conf, tmproot, masterCodeDir,
			topologyId, true);

	// tmproot/stormjar.jar
	String localFileJarTmp = StormConfig.stormjar_path(tmproot);

	// extract dir from jar
	JStormUtils.extract_dir_from_jar(localFileJarTmp,
			StormConfig.RESOURCES_SUBDIR, tmproot);

	FileUtils.moveDirectory(new File(tmproot), new File(stormroot));

}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:34,代码来源:SyncSupervisorEvent.java

示例8: Taskpage

import org.apache.thrift7.TException; //导入依赖的package包/类
public Taskpage() throws TException, NotAliveException {
	FacesContext ctx = FacesContext.getCurrentInstance();
	if (ctx.getExternalContext().getRequestParameterMap().get("clusterName") != null) {
		clusterName = ctx.getExternalContext()
				.getRequestParameterMap().get("clusterName");
	}
	if (ctx.getExternalContext().getRequestParameterMap().get("topologyid") != null) {
		topologyid = ctx.getExternalContext()
				.getRequestParameterMap().get("topologyid");
	}
	if (ctx.getExternalContext().getRequestParameterMap().get("taskid") != null) {
		taskid = ctx.getExternalContext().getRequestParameterMap()
				.get("taskid");
	}

	if (topologyid == null) {
		throw new NotAliveException("Input topologyId is null ");
	}

	window = UIUtils.getWindow(ctx);
	init();
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:23,代码来源:Taskpage.java

示例9: SpoutPage

import org.apache.thrift7.TException; //导入依赖的package包/类
public SpoutPage() throws TException, NotAliveException {
	FacesContext ctx = FacesContext.getCurrentInstance();
	if (ctx.getExternalContext().getRequestParameterMap().get("clusterName") != null) {
		clusterName = (String) ctx.getExternalContext()
				.getRequestParameterMap().get("clusterName");
	}
	
	if (ctx.getExternalContext().getRequestParameterMap().get("topologyid") != null) {
		topologyid = (String) ctx.getExternalContext()
				.getRequestParameterMap().get("topologyid");
	}

	if (ctx.getExternalContext().getRequestParameterMap()
			.get("componentid") != null) {
		componentid = (String) ctx.getExternalContext()
				.getRequestParameterMap().get("componentid");
	}

	window = UIUtils.getWindow(ctx);

	if (topologyid == null) {
		throw new NotAliveException("Input topologyId is null ");
	}

	init();
}
 
开发者ID:greeenSY,项目名称:Tstream,代码行数:27,代码来源:SpoutPage.java

示例10: getTopology

import org.apache.thrift7.TException; //导入依赖的package包/类
/**
 * get StormTopology throw deserialize local files
 * 
 * @param id
 *            String: topology id
 * @return StormTopology
 */
@Override
public StormTopology getTopology(String id) throws NotAliveException,
		TException {
	StormTopology topology = null;
	try {
		StormTopology stormtopology = StormConfig
				.read_nimbus_topology_code(conf, id);
		if (stormtopology == null) {
			throw new TException("topology:" + id + "is null");
		}

		Map<Object, Object> topologyConf = (Map<Object, Object>) StormConfig
				.read_nimbus_topology_conf(conf, id);

		topology = Common.system_topology(topologyConf, stormtopology);
	} catch (Exception e) {
		LOG.error("Failed to get topology " + id + ",", e);
		throw new TException("Failed to get system_topology");
	}
	return topology;
}
 
开发者ID:greeenSY,项目名称:Tstream,代码行数:29,代码来源:ServiceHandler.java

示例11: process

import org.apache.thrift7.TException; //导入依赖的package包/类
public boolean process(final TProtocol inProt, final TProtocol outProt) throws TException {
    //populating request context 
    ReqContext req_context = ReqContext.context();

    TTransport trans = inProt.getTransport();
    if (trans instanceof TMemoryInputTransport) {
        try {
            req_context.setRemoteAddress(InetAddress.getLocalHost());
        } catch (UnknownHostException e) {
            throw new RuntimeException(e);
        }                                
    } else if (trans instanceof TSocket) {
        TSocket tsocket = (TSocket)trans;
        //remote address
        Socket socket = tsocket.getSocket();
        req_context.setRemoteAddress(socket.getInetAddress());                
    } 

    //anonymous user
    req_context.setSubject(null);

    //invoke service handler
    return wrapped.process(inProt, outProt);
}
 
开发者ID:zhangjunfang,项目名称:jstorm-0.9.6.3-,代码行数:25,代码来源:SimpleTransportPlugin.java

示例12: downloadCodeFromMaster

import org.apache.thrift7.TException; //导入依赖的package包/类
/**
 * 创建{storm.local.dir}/nimbus/stormdist/topologyId目录
 * masterCodeDir:本地
 */
private void downloadCodeFromMaster(Assignment assignment, String topologyId) throws IOException, TException {
    try {
        String localRoot = StormConfig.masterStormdistRoot(data.getConf(), topologyId);
        String tmpDir = StormConfig.masterInbox(data.getConf()) + "/" + UUID.randomUUID().toString();
        String masterCodeDir = assignment.getMasterCodeDir();
        JStormServerUtils.downloadCodeFromMaster(data.getConf(), tmpDir, masterCodeDir, topologyId, false);

        FileUtils.moveDirectory(new File(tmpDir), new File(localRoot));
    } catch (TException e) {
        // TODO Auto-generated catch block
        LOG.error(e + " downloadStormCode failed " + "topologyId:" + topologyId + "masterCodeDir:"
                + assignment.getMasterCodeDir());
        throw e;
    }
    LOG.info("Finished downloading code for topology id " + topologyId + " from " + assignment.getMasterCodeDir());
}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:21,代码来源:FollowerRunnable.java

示例13: process

import org.apache.thrift7.TException; //导入依赖的package包/类
public boolean process(final TProtocol inProt, final TProtocol outProt)
		throws TException {
	// populating request context
	ReqContext req_context = ReqContext.context();

	TTransport trans = inProt.getTransport();
	// Sasl transport
	TSaslServerTransport saslTrans = (TSaslServerTransport) trans;

	// remote address
	TSocket tsocket = (TSocket) saslTrans.getUnderlyingTransport();
	Socket socket = tsocket.getSocket();
	req_context.setRemoteAddress(socket.getInetAddress());

	// remote subject
	SaslServer saslServer = saslTrans.getSaslServer();
	String authId = saslServer.getAuthorizationID();
	Subject remoteUser = new Subject();
	remoteUser.getPrincipals().add(new User(authId));
	req_context.setSubject(remoteUser);

	// invoke service handler
	return wrapped.process(inProt, outProt);
}
 
开发者ID:greeenSY,项目名称:Tstream,代码行数:25,代码来源:SaslTransportPlugin.java

示例14: Taskpage

import org.apache.thrift7.TException; //导入依赖的package包/类
public Taskpage() throws TException, NotAliveException {
	FacesContext ctx = FacesContext.getCurrentInstance();
	if (ctx.getExternalContext().getRequestParameterMap().get("clusterName") != null) {
		clusterName = (String) ctx.getExternalContext()
				.getRequestParameterMap().get("clusterName");
	}
	if (ctx.getExternalContext().getRequestParameterMap().get("topologyid") != null) {
		topologyid = (String) ctx.getExternalContext()
				.getRequestParameterMap().get("topologyid");
	}
	if (ctx.getExternalContext().getRequestParameterMap().get("taskid") != null) {
		taskid = (String) ctx.getExternalContext().getRequestParameterMap()
				.get("taskid");
	}

	if (topologyid == null) {
		throw new NotAliveException("Input topologyId is null ");
	}

	window = UIUtils.getWindow(ctx);
	init();
}
 
开发者ID:greeenSY,项目名称:Tstream,代码行数:23,代码来源:Taskpage.java

示例15: fail

import org.apache.thrift7.TException; //导入依赖的package包/类
@Override
public void fail(Object msgId) {
	DRPCMessageId did = (DRPCMessageId) msgId;
	DistributedRPCInvocations.Iface client;

	if (_local_drpc_id == null) {
		client = _clients.get(did.index);
	} else {
		client = (DistributedRPCInvocations.Iface) ServiceRegistry
				.getService(_local_drpc_id);
	}
	try {
		client.failRequest(did.id);
	} catch (TException e) {
		LOG.error("Failed to fail request", e);
	}
}
 
开发者ID:songtk,项目名称:learn_jstorm,代码行数:18,代码来源:DRPCSpout.java


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