Skip to content

Commit

Permalink
Merge pull request mesos#3 from dsKarthick/spammy-logs
Browse files Browse the repository at this point in the history
Improve few existing comments, add more comments for existing functions, delete a few unnecessary/irrelevant methods
  • Loading branch information
JessicaLHartog authored Jul 20, 2016
2 parents 3f901c7 + 29831fd commit 9caf60b
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 25 deletions.
4 changes: 0 additions & 4 deletions storm/src/main/storm/mesos/MesosNimbus.java
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,6 @@ public Collection<WorkerSlot> allSlotsAvailableForScheduling(
}
}

private String getLogViewerConfig() {
return String.format(" -c %s=true", MesosCommon.AUTO_START_LOGVIEWER_CONF);
}

/**
* This method is invoked after IScheduler.schedule assigns the worker slots to the topologies that need assignments
*
Expand Down
28 changes: 16 additions & 12 deletions storm/src/main/storm/mesos/resources/AggregatedOffers.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ private void initializeAvailableResources() {
availableResources.put(ResourceType.PORTS, new RangeResource(ResourceType.PORTS));
}

public AggregatedOffers(String hostName) {
this.hostName = hostName;
initializeAvailableResources();
}

public AggregatedOffers(Protos.Offer offer) {
initializeAvailableResources();
this.slaveID = offer.getSlaveId();
Expand All @@ -64,7 +59,7 @@ public String getHostName() {
}

public void add(Protos.Offer offer) {
// We are unable to aggregate offers if they are from different workers
// We are unable to aggregate offers if they are from different mesos slaves/workers/agents
assert offer.getSlaveId().equals(slaveID) && offer.getHostname().equals(hostName);
offerList.add(offer);

Expand Down Expand Up @@ -103,6 +98,11 @@ public boolean isAvailable(ResourceType resourceType, ResourceEntry<?> resource)
return availableResources.get(resourceType).isAvailable(resource);
}

/**
* Unused Method - Exists for the purpose of facilitating support of reservations.
* TODO: Support reservations (https://github.com/mesos/storm/issues/148)
* For more information about why this unused code exists, see discussion: https://github.com/mesos/storm/pull/146#issuecomment-225496075
*/
public boolean isAvailable(ResourceType resourceType, ReservationType reservationType, ResourceEntry<?> resource) {
return availableResources.get(resourceType).isAvailable(resource, reservationType);
}
Expand All @@ -111,6 +111,11 @@ public <T extends ResourceEntry> List<T> getAllAvailableResources(ResourceType r
return availableResources.get(resourceType).getAllAvailableResources();
}

/**
* Unused Method - Exists for the purpose of facilitating support of reservations.
* TODO: Support reservations (https://github.com/mesos/storm/issues/148)
* For more information about why this unused code exists, see discussion: https://github.com/mesos/storm/pull/146#issuecomment-225496075
*/
public <T extends ResourceEntry> List<T> getAllAvailableResources(ResourceType resourceType, ReservationType reservationType) {
return availableResources.get(resourceType).getAllAvailableResources(reservationType);
}
Expand All @@ -128,6 +133,11 @@ public List<ResourceEntry> reserveAndGet(ResourceType resourceType, ResourceEntr
return new ArrayList<>();
}

/**
* Unused Method - Exists for the purpose of facilitating support of reservations.
* TODO: Support reservations (https://github.com/mesos/storm/issues/148)
* For more information about why this unused code exists, see discussion: https://github.com/mesos/storm/pull/146#issuecomment-225496075
*/
public List<ResourceEntry> reserveAndGet(ResourceType resourceType, ReservationType reservationType, ResourceEntry<?> resource) throws
ResourceNotAvailableException {
if (availableResources.get(resourceType).isAvailable(resource, reservationType)) {
Expand All @@ -136,10 +146,6 @@ public List<ResourceEntry> reserveAndGet(ResourceType resourceType, ReservationT
return new ArrayList<>();
}

public List<Protos.Offer> getOfferList() {
return offerList;
}

public List<Protos.OfferID> getOfferIDList() {
List<Protos.OfferID> offerIDList = new ArrayList<>();
for (Protos.Offer offer: offerList) {
Expand All @@ -162,7 +168,6 @@ public String toString() {


public boolean isFit(Map mesosStormConf, TopologyDetails topologyDetails, boolean supervisorExists) {

double requestedWorkerCpu = MesosCommon.topologyWorkerCpu(mesosStormConf, topologyDetails);
double requestedWorkerMem = MesosCommon.topologyWorkerMem(mesosStormConf, topologyDetails);

Expand All @@ -175,7 +180,6 @@ public boolean isFit(Map mesosStormConf, TopologyDetails topologyDetails, boolea
}

public boolean isFit(Map mesosStormConf, TopologyDetails topologyDetails, Long port, boolean supervisorExists) {

double requestedWorkerCpu = MesosCommon.topologyWorkerCpu(mesosStormConf, topologyDetails);
double requestedWorkerMem = MesosCommon.topologyWorkerMem(mesosStormConf, topologyDetails);

Expand Down
10 changes: 9 additions & 1 deletion storm/src/main/storm/mesos/resources/RangeResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,15 @@ public List<ResourceEntry> removeAndGet(RangeResourceEntry rangeResourceEntry) t


/**
* Unused Method - Exists for the purpose of facilitating support of reservations.
* TODO: Support reservations (https://github.com/mesos/storm/issues/148)
* For more information about why this unused code exists, see discussion: https://github.com/mesos/storm/pull/146#issuecomment-225496075
*
* Remove/Reserve range from available ranges.
* {@param rangeResourceEntry} range resource to removeAndGet
* {@param reservationType} reservation type of resource that needs to be removed. If the resource represented by rangeResourceEntry
* of the reservation type specified by this parameter is not available, then {@link ResourceNotAvailableException}
* is thrown
* is thrown.
*/
@Override
public List<ResourceEntry> removeAndGet(RangeResourceEntry rangeResourceEntry, ReservationType reservationType) throws ResourceNotAvailableException {
Expand All @@ -129,6 +133,10 @@ public List<ResourceEntry> removeAndGet(RangeResourceEntry rangeResourceEntry, R
}

/**
* Unused Method - Exists for the purpose of facilitating support of reservations.
* TODO: Support reservations (https://github.com/mesos/storm/issues/148)
* For more information about why this unused code exists, see discussion: https://github.com/mesos/storm/pull/146#issuecomment-225496075
*
* Remove/Reserve range from available ranges
* {@param rangeResourceEntry} range resource to removeAndGet
* {@param reservationTypeComparator} comparator like {@link storm.mesos.resources.DefaultReservationTypeComparator}
Expand Down
10 changes: 10 additions & 0 deletions storm/src/main/storm/mesos/resources/Resource.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,18 @@ public interface Resource<T extends ResourceEntry<? extends Number>> {

public List<ResourceEntry> removeAndGet(T resourceEntry) throws ResourceNotAvailableException;

/**
* Unused Method - Exists for the purpose of facilitating support of reservations.
* TODO: Support reservations (https://github.com/mesos/storm/issues/148)
* For more information about why this unused code exists, see discussion: https://github.com/mesos/storm/pull/146#issuecomment-225496075
*/
public List<ResourceEntry> removeAndGet(T value, ReservationType reservationType) throws ResourceNotAvailableException;

/**
* Unused Method - Exists for the purpose of facilitating support of reservations.
* TODO: Support reservations (https://github.com/mesos/storm/issues/148)
* For more information about why this unused code exists, see discussion: https://github.com/mesos/storm/pull/146#issuecomment-225496075
*/
public List<ResourceEntry> removeAndGet(T value, Comparator<ReservationType> reservationTypeComparator) throws ResourceNotAvailableException;

}
5 changes: 5 additions & 0 deletions storm/src/main/storm/mesos/resources/ResourceEntries.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ public ReservationType getReservationType() {
}

/**
* Unused Method - Exists for the sake of completeness in terms of implementing ResourceEntry<T>.
*
* Lets say, we have a range [u,v]. Using this add function, we can expand the range to [w,x] if and
* only if one of the following conditions are satisfied
* `w < u`
Expand All @@ -107,6 +109,9 @@ public RangeResourceEntry add(ResourceEntry<Long> resourceEntry) {
return this;
}

/**
* Unused Method - Exists for the sake of completeness in terms of implementing ResourceEntry<T>.
*/
public RangeResourceEntry remove(ResourceEntry<Long> resourceEntry) {
RangeResourceEntry rangeResourceEntry = (RangeResourceEntry) resourceEntry;
if (this.begin < rangeResourceEntry.getBegin()) {
Expand Down
13 changes: 5 additions & 8 deletions storm/src/main/storm/mesos/resources/ScalarResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ public boolean isAvailable(ScalarResourceEntry scalarResourceEntry, ReservationT
return (availableResourcesByReservationType.get(reservationType).getValue() >= scalarResourceEntry.getValue());
}

/**
* Unused Method - Exists for the purpose of facilitating support of reservations.
* TODO: Support reservations (https://github.com/mesos/storm/issues/148)
* For more information about why this unused code exists, see discussion: https://github.com/mesos/storm/pull/146#issuecomment-225496075
*/
public Double getTotalAvailableResource(ReservationType reservationType) {
return availableResourcesByReservationType.get(reservationType).getValue();
}
Expand Down Expand Up @@ -82,14 +87,6 @@ public List<ResourceEntry> removeAndGet(ScalarResourceEntry scalarResourceEntry)
return removeAndGet(scalarResourceEntry, availableResourcesByReservationType.keySet());
}

public List<ResourceEntry> reserveScalarResource(ResourceType resourceType, ScalarResourceEntry requiredValue) throws ResourceNotAvailableException {
if (totalAvailableResource < requiredValue.getValue()) {
throw new ResourceNotAvailableException(String.format("resourceType: {} is not available. Requested {} Available {}",
resourceType, requiredValue, totalAvailableResource));
}
return removeAndGet(requiredValue);
}

/**
* Removes/Reserves scalar resource from available resources.
* {@param scalarResourceEntry} amount of scalar resource to removeAndGet/decrement
Expand Down

0 comments on commit 9caf60b

Please sign in to comment.