alluxio.master.meta.MasterInfo Maven / Gradle / Ivy
/*
* 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.master.meta;
import alluxio.wire.Address;
import com.google.common.base.MoreObjects;
import com.google.common.base.Preconditions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.annotation.concurrent.NotThreadSafe;
/**
* Master information.
*/
@NotThreadSafe
public final class MasterInfo {
private static final Logger LOG = LoggerFactory.getLogger(MasterInfo.class);
/** Master's address. */
private final Address mAddress;
/** The id of the master. */
private final long mId;
/** Master's last updated time in ms. */
private long mLastUpdatedTimeMs;
/**
* Creates a new instance of {@link MasterInfo}.
*
* @param id the master id to use
* @param address the master address to use
*/
public MasterInfo(long id, Address address) {
mAddress = Preconditions.checkNotNull(address, "address");
mId = id;
mLastUpdatedTimeMs = System.currentTimeMillis();
}
/**
* @return the master's address
*/
public Address getAddress() {
return mAddress;
}
/**
* @return the id of the master
*/
public long getId() {
return mId;
}
/**
* @return the last updated time of the master in ms
*/
public long getLastUpdatedTimeMs() {
return mLastUpdatedTimeMs;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(this).add("id", mId).add("address", mAddress)
.add("lastUpdatedTimeMs", mLastUpdatedTimeMs).toString();
}
/**
* Updates the last updated time of the master in ms.
*/
public void updateLastUpdatedTimeMs() {
mLastUpdatedTimeMs = System.currentTimeMillis();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy