package com.boundary.metrics.vmware.poller;

import java.util.Map;

import org.joda.time.DateTime;

import com.boundary.metrics.vmware.client.client.meter.manager.MeterManagerClient;
import com.boundary.metrics.vmware.client.metrics.Metric;
import com.boundary.metrics.vmware.client.metrics.MetricsClient;
import com.boundary.metrics.vmware.util.TimeUtils;
import com.vmware.connection.Connection;
import com.vmware.vim25.ManagedObjectReference;
import com.vmware.vim25.PerfCounterInfo;
import com.vmware.vim25.RuntimeFaultFaultMsg;

/**
 * Encapsulates all the necessary resources to collect metrics from
 * vSphere endpoint by the {@link VMWareMetricCollector}
 *
 */
public class VMWareCollectionJob {
	
	private final VMWareMetadata metadata;
	private final Connection vmwareClient;
	private final MetricsClient metricsClient;
	private final MeterManagerClient meterClient;
	
	/**
	 * Consteructor
	 * @param metadata {@link VMWareMetadata} all data required to collect metrics
	 * @param vmwareClient Handles connection to vSphere end point
	 * @param metricsClient Handles metrics API connection to Boundary
	 * @param meterManagerClient Handles meter API connection to Boundary
	 */
	public VMWareCollectionJob(VMWareMetadata metadata,Connection vmwareClient,
			MetricsClient metricsClient,MeterManagerClient meterClient) {
		this.metadata = metadata;
		this.vmwareClient = vmwareClient;
		this.metricsClient = metricsClient;
		this.meterClient = meterClient;
	}

	public ManagedObjectReference getRootMOR() {
		return vmwareClient.getServiceContent().getRootFolder();
	}

	public DateTime getTimeAtEndPoint() throws RuntimeFaultFaultMsg {
		return TimeUtils.toDateTime(vmwareClient.getVimPort().currentTime(vmwareClient.getServiceInstanceReference()));
	}

	public String getHost() {
		return vmwareClient.getHost();
	}

	public Map<String, Integer> getPerformanceCounterMap() {
		return metadata.getPerformanceCounterMap();
	}

	public Map<String,Metric> getMetrics() {
		return metadata.getMetrics();
	}

	public Connection getVMWareClient() {
		return this.vmwareClient;
	}

	public Map<Integer, PerfCounterInfo> getPerformanceCounterInfoMap() {
		return metadata.getPerformanceCounterInfoMap();
	}

	public MeterManagerClient getMeterClient() {
		return this.meterClient;
	}

	public String getOrgId() {
		return metadata.getOrgId();
	}

	public MetricsClient getMetricsClient() {
		return this.metricsClient;
	}
}

@@ -1,8 +1,600 @@
+// Copyright 2014 Boundary, Inc.%0A//%0A// Licensed under the Apache License, Version 2.0 (the %22License%22);%0A// you may not use this file except in compliance with the License.%0A// You may obtain a copy of the License at%0A//%0A//     http://www.apache.org/licenses/LICENSE-2.0%0A//%0A// Unless required by applicable law or agreed to in writing, software%0A// distributed under the License is distributed on an %22AS IS%22 BASIS,%0A// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A// See the License for the specific language governing permissions and%0A// limitations under the License.%0A%0A
 package 
@@ -1268,22 +1268,22 @@
 c class 
-VMWare
+Metric
 Collecti
@@ -1347,26 +1347,28 @@
 e final 
-Connection
+VMwareClient
  vmwareC
@@ -1588,24 +1588,45 @@
 vmwareClient
+ %7B@link VMwareClient%7D
  Handles con
@@ -1674,24 +1674,46 @@
 etricsClient
+ %7B@link MetricsClient%7D
  Handles met
@@ -1773,16 +1773,43 @@
 erClient
+ %7B@link MeterManagerClient%7D
  Handles
@@ -1855,22 +1855,22 @@
 %09public 
-VMWare
+Metric
 Collecti
@@ -1899,26 +1899,28 @@
 etadata,
-Connection
+VMwareClient
  vmwareC
@@ -2244,193 +2244,8 @@
 %09%7D%0A%0A
-%09public DateTime getTimeAtEndPoint() throws RuntimeFaultFaultMsg %7B%0A%09%09return TimeUtils.toDateTime(vmwareClient.getVimPort().currentTime(vmwareClient.getServiceInstanceReference()));%0A%09%7D%0A%0A
 %09pub
@@ -2498,26 +2498,28 @@
 %09public 
-Connection
+VMwareClient
  getVMWa

Add license ; change reference to using VMwareClient instead of generic Connection