本文整理汇总了Java中com.trulia.thoth.pojo.ServerDetail类的典型用法代码示例。如果您正苦于以下问题:Java ServerDetail类的具体用法?Java ServerDetail怎么用?Java ServerDetail使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ServerDetail类属于com.trulia.thoth.pojo包,在下文中一共展示了ServerDetail类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: retrieveMonitorsForServer
import com.trulia.thoth.pojo.ServerDetail; //导入依赖的package包/类
/**
* Retrieve list of available Monitors
* @param serverDetail server to monitor
* @return list of monitors ready to be executed
*/
public List<Monitor> retrieveMonitorsForServer(ServerDetail serverDetail) {
List<Monitor> monitors = new ArrayList<Monitor>();
ArrayList<Class> monitorClasses = (ArrayList<Class>) availableMonitors.getMonitorList();
try{
for (Class klass: monitorClasses){
Monitor obj = (Monitor) klass.newInstance();
// Set default variables for Monitors
obj.serverDetail = serverDetail;
obj.realtimeThoth = realTimeThoth;
obj.shrankThoth = historicalDataThoth;
obj.mailer = mailer;
monitors.add(obj);
}
} catch (Exception e){
e.printStackTrace();
}
return monitors;
}
示例2: createDocumentShrinkers
import com.trulia.thoth.pojo.ServerDetail; //导入依赖的package包/类
public void createDocumentShrinkers() throws SolrServerException, InterruptedException, ExecutionException {
ExecutorService service = Executors.newFixedThreadPool(threadPoolSize);
CompletionService<String> completionService = new ExecutorCompletionService<String>(service);
HttpSolrServer thothServer = new HttpSolrServer(thothIndexUrl + realTimeCore);
HttpSolrServer thothShrankServer = new HttpSolrServer(thothIndexUrl + shrankCore);
ArrayList<ServerDetail> listOfServers = new ThothServers().getList(thothServer);
for (ServerDetail serverDetail: listOfServers){
LOG.info("Shrinking docs for server("+serverDetail.getName()+"):("+serverDetail.getPort()+") ");
completionService.submit(new DocumentShrinker(serverDetail, nowMinusTimeToShrink, thothServer, thothShrankServer));
}
// Wait for all the executors to finish
for(int i = 0; i < listOfServers.size(); i++){
completionService.take().get();
}
LOG.info("Done Shrinking.");
}
示例3: getList
import com.trulia.thoth.pojo.ServerDetail; //导入依赖的package包/类
public ArrayList<ServerDetail> getList(SolrServer realTimeThoth) throws SolrServerException {
ArrayList<ServerDetail> serverDetails = new ArrayList<ServerDetail>();
// Using HierarchicalFaceting to fetch server details .http://wiki.apache.org/solr/HierarchicalFaceting
QueryResponse qr = realTimeThoth.query(new SolrQuery("*:*").addFacetPivotField(FACET_PIVOT_FIELDS).setRows(0).setFacetLimit(FACET_LIMIT));
NamedList<List<PivotField>> pivots = qr.getFacetPivot();
System.out.println("Found " + pivots.get(FACET_PIVOT_FIELDS).size()+" servers to monitor. Fetching information for these servers. Please wait");
for (PivotField pivot: pivots.get(FACET_PIVOT_FIELDS)){
String hostname = (String) pivot.getValue();
for (PivotField pf: pivot.getPivot()){
String coreName = (String) pf.getValue();
ServerDetail detail = fetchServerDetails(hostname,coreName, realTimeThoth);
if (detail != null) serverDetails.add(detail);
}
}
return serverDetails;
}
示例4: isIgnored
import com.trulia.thoth.pojo.ServerDetail; //导入依赖的package包/类
/**
* Check if server is part of the ignored servers
* @param serverDetail server to check
* @return true if ignored , false if not
*/
private boolean isIgnored(ServerDetail serverDetail){
for (ServerDetail toCheck: ignoredServerDetails){
if ((toCheck.getName().equals(serverDetail.getName())) &&
(toCheck.getCore().equals(serverDetail.getCore())) &&
(toCheck.getPool().equals(serverDetail.getPool())) &&
(toCheck.getPort().equals(serverDetail.getPort()))){
return true;
}
}
return false;
}
示例5: executeMonitorsConcurrently
import com.trulia.thoth.pojo.ServerDetail; //导入依赖的package包/类
/**
* Execute all the monitors on the server , concurrently
* @param serverDetail server to monitor
* @throws InterruptedException
*/
public void executeMonitorsConcurrently(ServerDetail serverDetail) throws InterruptedException, InvocationTargetException, NoSuchMethodException, InstantiationException, IllegalAccessException, ClassNotFoundException {
List<Monitor> monitorList = retrieveMonitorsForServer(serverDetail);
if (monitorList.size() == 0) {
System.out.println("No monitors found for server (" + serverDetail.getName() + ") port(" + serverDetail.getPort() + ") coreName(" + serverDetail.getCore() + "). Skipping ...");
} else {
System.out.println("Found "+monitorList.size()+" monitor/s for server (" + serverDetail.getName() + ") port(" + serverDetail.getPort() + ") coreName(" + serverDetail.getCore() + ")");
List<Future<MonitorResult>> futures = new ArrayList<Future<MonitorResult>>();
// Create a pool of threads, numberOfMonitors max jobs will execute in parallel
ExecutorService monitorsThreadPool = Executors.newFixedThreadPool(monitorList.size());
for (Monitor monitor : monitorList) {
futures.add(monitorsThreadPool.submit(monitor));
}
for (Future f : futures) {
try {
// Check if all the threads are finished.
MonitorResult monitorResult = (MonitorResult) f.get(); // TODO
} catch (ExecutionException e) {
System.out.println("Exception in executeMonitorsConcurrently, while checking the threads status");
e.getCause().printStackTrace();
}
}
}
System.out.println("Finished monitoring server (" + serverDetail.getName() + ") port(" + serverDetail.getPort() + ") coreName(" + serverDetail.getCore() + ")");
}
示例6: execute
import com.trulia.thoth.pojo.ServerDetail; //导入依赖的package包/类
@Override
public void execute(JobExecutionContext context) throws JobExecutionException {
SchedulerContext schedulerContext = null;
try {
schedulerContext = context.getScheduler().getContext();
realTimeThoth = new HttpSolrServer(schedulerContext.get("thothIndexURI") + realTimeThothCore);
historicalDataThoth = new HttpSolrServer(schedulerContext.get("thothIndexURI") + shrankThothCore);
serverCache = (ServerCache) schedulerContext.get("serverCache");
ignoredServerDetails = (ArrayList<ServerDetail>) schedulerContext.get("ignoredServers");
isPredictorMonitoringEnabled = (Boolean) schedulerContext.get("isPredictorMonitoringEnabled");
availableMonitors = (AvailableMonitors) schedulerContext.get("availableMonitors");
mailer = (Mailer) schedulerContext.get("mailer");
//TODO remove?
monitorThothPredictor(schedulerContext);
// Get the list of servers to Monitor from Thoth
List<ServerDetail> serversToMonitor = new ThothServers().getList(realTimeThoth);
System.out.println("Fetching information about the servers done. Start the monitoring");
for (ServerDetail serverDetail: serversToMonitor){
if (isIgnored(serverDetail)) continue; // Skip server if ignored
System.out.println("Start monitoring server (" + serverDetail.getName()+") port(" + serverDetail.getPort()+") coreName("+ serverDetail.getCore()+ ")");
executeMonitorsConcurrently(serverDetail);
}
if (serversToMonitor.size() == 0) System.out.println("No suitable thoth documents found for monitoring. Skipping...");
System.out.println("Done with monitoring.");
realTimeThoth.shutdown();
historicalDataThoth.shutdown();
} catch (Exception e){
e.printStackTrace();
}
}
示例7: retrieveIgnoredServerDetails
import com.trulia.thoth.pojo.ServerDetail; //导入依赖的package包/类
private void retrieveIgnoredServerDetails(){
ignoredServerDetails = new ArrayList<ServerDetail>();
for (String ignoredServer: ignoredServers.split(",")){
String[] splitted = ignoredServer.split(";");
if (splitted.length % 4 == 0) ignoredServerDetails.add(new ServerDetail(splitted[0], splitted[3], splitted[1], splitted[2]));
}
}
示例8: add
import com.trulia.thoth.pojo.ServerDetail; //导入依赖的package包/类
public void add(ServerDetail detail){
String hostname = detail.getName();
String coreName = detail.getCore();
String key = hostname +" "+coreName;
serverList.put(key, detail);
System.out.println("ServerCache: added hostname("+hostname+") core("+coreName+") to the cache.");
}
示例9: SamplerWorker
import com.trulia.thoth.pojo.ServerDetail; //导入依赖的package包/类
public SamplerWorker(ServerDetail server, String samplingDirectory, ObjectMapper mapper, HttpSolrServer thothIndex, ModelHealth modelHealth) throws IOException {
this.server = server;
this.mapper = mapper;
DateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd");
Date date = new Date();
this.fileName = samplingDirectory + dateFormat.format(date) + "_" + server.getName();
writer = new BufferedWriter(new FileWriter(new File(fileName), true));
this.hostname = server.getName();
this.pool = server.getPool();
this.core = server.getCore();
this.port = server.getPort();
this.thothIndex = thothIndex;
this.modelHealth = modelHealth;
}
示例10: DocumentShrinker
import com.trulia.thoth.pojo.ServerDetail; //导入依赖的package包/类
public DocumentShrinker(ServerDetail serverDetail, DateTime nowMinusTimeToShrink, HttpSolrServer thothServer, HttpSolrServer thothShrankServer) {
this.shrankServer = thothShrankServer;
this.realTimeServer = thothServer;
this.nowMinusTimeToShrink = nowMinusTimeToShrink;
this.serverDetail = serverDetail;
}
示例11: isServerIgnored
import com.trulia.thoth.pojo.ServerDetail; //导入依赖的package包/类
/**
* Check if server is part of the ignored servers
* @param serverDetail server to check
* @return true if ignored , false if not
*/
public boolean isServerIgnored(ServerDetail serverDetail){
for (ServerDetail toCheck: ignoredServerDetails){
if ((toCheck.getName().equals(serverDetail.getName())) &&
(toCheck.getCore().equals(serverDetail.getCore())) &&
(toCheck.getPool().equals(serverDetail.getPool())) &&
(toCheck.getPort().equals(serverDetail.getPort()))){
return true;
}
}
return false;
}
示例12: init
import com.trulia.thoth.pojo.ServerDetail; //导入依赖的package包/类
public void init() {
this.serverList = new HashMap<String, ServerDetail>();
}
示例13: fetchDetails
import com.trulia.thoth.pojo.ServerDetail; //导入依赖的package包/类
public ServerDetail fetchDetails(String hostname, String coreName){
System.out.println("ServerCache: fetching hostname("+hostname+") core("+coreName+") from the cache.");
return serverList.get(hostname + " " + coreName);
}
示例14: getIgnoredServersDetail
import com.trulia.thoth.pojo.ServerDetail; //导入依赖的package包/类
public ArrayList<ServerDetail> getIgnoredServersDetail(){
return this.ignoredServerDetails;
}
示例15: IgnoredServers
import com.trulia.thoth.pojo.ServerDetail; //导入依赖的package包/类
public IgnoredServers(ArrayList<ServerDetail> ignoredServerDetails){
this.ignoredServerDetails = ignoredServerDetails;
}