Skip to content

Commit

Permalink
Consolidate Alluxio Master REST Service endpoints.
Browse files Browse the repository at this point in the history
  • Loading branch information
jsimsa committed Aug 24, 2016
1 parent 792a537 commit 8a7affb
Show file tree
Hide file tree
Showing 5 changed files with 411 additions and 327 deletions.
230 changes: 230 additions & 0 deletions core/common/src/main/java/alluxio/wire/AlluxioMasterInfo.java
@@ -0,0 +1,230 @@
/*
* The Alluxio Open Foundation licenses this work under the Apache License, version 2.0
* (the "License"). You may not use this work except in compliance with the License, which is
* available at www.apache.org/licenses/LICENSE-2.0
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied, as more fully set forth in the License.
*
* See the NOTICE file distributed with this work for information regarding copyright ownership.
*/

package alluxio.wire;

import com.google.common.base.Objects;

import java.util.List;
import java.util.Map;

/**
* Alluxio master descriptor.
*/
public class AlluxioMasterInfo {
private Capacity mCapacity;
private Map<String, String> mConfiguration;
private Map<String, Long> mMetrics;
private String mRpcAddress;
private long mStartTimeMs;
private Map<String, Capacity> mTierCapacity;
private Capacity mUfsCapacity;
private long mUptimeMs;
private String mVersion;
private List<WorkerInfo> mWorkers;

/**
* Creates a new instance of {@link AlluxioMasterInfo}.
*/
public AlluxioMasterInfo() {}

/**
* @return the capacity
*/
public Capacity getCapacity() {
return mCapacity;
}

/**
* @return the configuration
*/
public Map<String, String> getConfiguration() {
return mConfiguration;
}

/**
* @return the metrics
*/
public Map<String, Long> getMetrics() {
return mMetrics;
}

/**
* @return the RPC address
*/
public String getRpcAddress() {
return mRpcAddress;
}

/**
* @return the start time (in milliseconds)
*/
public long getStartTimeMs() {
return mStartTimeMs;
}

/**
* @return the capacity per tier
*/
public Map<String, Capacity> getTierCapacity() {
return mTierCapacity;
}

/**
* @return the UFS capacity
*/
public Capacity getUfsCapacity() {
return mCapacity;
}

/**
* @return the uptime (in milliseconds)
*/
public long getUptimeMs() {
return mUptimeMs;
}

/**
* @return the version
*/
public String getVersion() {
return mVersion;
}

/**
* @return the list of workers
*/
public List<WorkerInfo> getWorkers() {
return mWorkers;
}

/**
* @param capacity the capacity to use
* @return the Alluxio master descriptor
*/
public AlluxioMasterInfo setCapacity(Capacity capacity) {
mCapacity = capacity;
return this;
}

/**
* @param configuration the configuration to use
* @return the Alluxio master descriptor
*/
public AlluxioMasterInfo setConfiguration(Map<String, String> configuration) {
mConfiguration = configuration;
return this;
}

/**
* @param metrics the metrics to use
* @return the Alluxio master descriptor
*/
public AlluxioMasterInfo setMetrics(Map<String, Long> metrics) {
mMetrics = metrics;
return this;
}

/**
* @param rpcAddress the RPC address to use
* @return the Alluxio master descriptor
*/
public AlluxioMasterInfo setRpcAddress(String rpcAddress) {
mRpcAddress = rpcAddress;
return this;
}

/**
* @param startTimeMs the start time to use (in milliseconds)
* @return the Alluxio master descriptor
*/
public AlluxioMasterInfo setStartTimeMs(long startTimeMs) {
mStartTimeMs = startTimeMs;
return this;
}

/**
* @param tierCapacity the capacity per tier to use
* @return the Alluxio master descriptor
*/
public AlluxioMasterInfo setTierCapacity(Map<String, Capacity> tierCapacity) {
mTierCapacity = tierCapacity;
return this;
}

/**
* @param ufsCapacity the UFS capacity to use
* @return the Alluxio master descriptor
*/
public AlluxioMasterInfo setUfsCapacity(Capacity ufsCapacity) {
mUfsCapacity = ufsCapacity;
return this;
}

/**
* @param uptimeMs the uptime to use (in milliseconds)
* @return the Alluxio master descriptor
*/
public AlluxioMasterInfo setUptimeMs(long uptimeMs) {
mUptimeMs = uptimeMs;
return this;
}

/**
* @param version the version to use
* @return the Alluxio master descriptor
*/
public AlluxioMasterInfo setVersion(String version) {
mVersion = version;
return this;
}

/**
* @param workers the list of workers to use
* @return the Alluxio master descriptor
*/
public AlluxioMasterInfo setWorkers(List<WorkerInfo> workers) {
mWorkers = workers;
return this;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof AlluxioMasterInfo)) {
return false;
}
AlluxioMasterInfo that = (AlluxioMasterInfo) o;
return mCapacity.equals(that.mCapacity) && mConfiguration.equals(that.mConfiguration)
&& mMetrics.equals(that.mMetrics) && mRpcAddress.equals(that.mRpcAddress)
&& mStartTimeMs == that.mStartTimeMs && mTierCapacity.equals(that.mTierCapacity)
&& mUfsCapacity.equals(that.mUfsCapacity) && mUptimeMs == that.mUptimeMs && mVersion
.equals(that.mVersion) && mWorkers.equals(that.mWorkers);
}

@Override
public int hashCode() {
return Objects
.hashCode(mCapacity, mConfiguration, mMetrics, mRpcAddress, mStartTimeMs, mTierCapacity,
mUfsCapacity, mUptimeMs, mVersion, mWorkers);
}

@Override
public String toString() {
return Objects.toStringHelper(this).add("capacity", mCapacity)
.add("configuration", mConfiguration).add("metrics", mMetrics)
.add("rpc address", mRpcAddress).add("start time", mStartTimeMs)
.add("tier capacity", mTierCapacity).add("ufs capacity", mUfsCapacity)
.add("uptime", mUptimeMs).add("version", mVersion).add("workers", mWorkers).toString();
}
}
24 changes: 24 additions & 0 deletions core/common/src/main/java/alluxio/wire/AlluxioWorkerInfo.java
@@ -0,0 +1,24 @@
/*
* The Alluxio Open Foundation licenses this work under the Apache License, version 2.0
* (the "License"). You may not use this work except in compliance with the License, which is
* available at www.apache.org/licenses/LICENSE-2.0
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied, as more fully set forth in the License.
*
* See the NOTICE file distributed with this work for information regarding copyright ownership.
*/

package alluxio.wire;

/**
* Alluxio worker descriptor.
*/
public class AlluxioWorkerInfo {

/**
* Creates a new instance of {@link AlluxioWorkerInfo}.
*/
public AlluxioWorkerInfo() {}

}
81 changes: 81 additions & 0 deletions core/common/src/main/java/alluxio/wire/Capacity.java
@@ -0,0 +1,81 @@
/*
* The Alluxio Open Foundation licenses this work under the Apache License, version 2.0
* (the "License"). You may not use this work except in compliance with the License, which is
* available at www.apache.org/licenses/LICENSE-2.0
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
* either express or implied, as more fully set forth in the License.
*
* See the NOTICE file distributed with this work for information regarding copyright ownership.
*/

package alluxio.wire;

import com.google.common.base.Objects;

/**
* Class that represents the available, free, and total capacity.
*/
public class Capacity {
private long mTotal;
private long mUsed;

/**
* Creates a new instance of {@link Capacity}.
*/
public Capacity() {}

/**
* @return the total capacity
*/
public long getTotal() {
return mTotal;
}

/**
* @return the used capacity
*/
public long getUsed() {
return mUsed;
}

/**
* @param total the total capacity to use
* @return the capacity
*/
public Capacity setTotal(long total) {
mTotal = total;
return this;
}

/**
* @param used the used capacity to use
* @return the capacity
*/
public Capacity setUsed(long used) {
mUsed = used;
return this;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (!(o instanceof Capacity)) {
return false;
}
Capacity that = (Capacity) o;
return mTotal == that.mTotal && mUsed == that.mUsed;
}

@Override
public int hashCode() {
return Objects.hashCode(mTotal, mUsed);
}

@Override
public String toString() {
return Objects.toStringHelper(this).add("total", mTotal).add("used", mUsed).toString();
}
}

0 comments on commit 8a7affb

Please sign in to comment.