Add Javadocs

Also a minor fix to the phrasing in `MarvelLicensee#expirationMessages()`.

Original commit: elastic/x-pack-elasticsearch@9366c07930
This commit is contained in:
Chris Earle 2016-02-21 17:12:16 -05:00
parent 0b0ca8f2a6
commit ef81157c47
3 changed files with 72 additions and 10 deletions

View File

@ -29,6 +29,15 @@ import java.util.Locale;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
/**
* The {@code AgentService} is a service that does the work of publishing the details to the monitoring cluster.
* <p>
* If this service is stopped, then the attached, monitored node is not going to publish its details to the monitoring cluster. Given
* service life cycles, the intended way to temporarily stop the publishing is using the start and stop collection methods.
*
* @see #stopCollection()
* @see #startCollection()
*/
public class AgentService extends AbstractLifecycleComponent<AgentService> { public class AgentService extends AbstractLifecycleComponent<AgentService> {
private volatile ExportingWorker exportingWorker; private volatile ExportingWorker exportingWorker;

View File

@ -11,9 +11,22 @@ import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
/** /**
* Renderers are used to render documents using a given OutputStream. * {@code Renderer}s are used to render documents using a given OutputStream.
* <p>
* Each {@code Renderer} can be thought of as a generator of a unique document <em>type</em> within the resulting ES index. For example,
* there will be details about shards, which requires a unique document type and there will also be details about indices, which requires
* their own unique documents.
*
* @see AbstractRenderer
*/ */
public interface Renderer<T> { public interface Renderer<T> {
/**
* Convert the given {@code document} type into something that can be sent to the monitoring cluster.
*
* @param document The arbitrary document (e.g., details about a shard)
* @param xContentType The rendered content type (e.g., JSON)
* @param os The buffer
* @throws IOException if any unexpected error occurs
*/
void render(T document, XContentType xContentType, OutputStream os) throws IOException; void render(T document, XContentType xContentType, OutputStream os) throws IOException;
} }

View File

@ -16,7 +16,15 @@ import org.elasticsearch.license.plugin.core.Licensee;
import org.elasticsearch.license.plugin.core.LicenseeRegistry; import org.elasticsearch.license.plugin.core.LicenseeRegistry;
import org.elasticsearch.marvel.Marvel; import org.elasticsearch.marvel.Marvel;
/**
* {@code MarvelLicensee} determines whether certain features of Monitoring are enabled or disabled.
* <p>
* Once the license expires, the agent will stop:
* <ul>
* <li>Collecting and publishing new metrics.</li>
* <li>Cleaning up (deleting) older indices.</li>
* </ul>
*/
public class MarvelLicensee extends AbstractLicenseeComponent<MarvelLicensee> implements Licensee { public class MarvelLicensee extends AbstractLicenseeComponent<MarvelLicensee> implements Licensee {
@Inject @Inject
@ -24,11 +32,17 @@ public class MarvelLicensee extends AbstractLicenseeComponent<MarvelLicensee> im
super(settings, Marvel.NAME, clientService); super(settings, Marvel.NAME, clientService);
} }
/**
* {@inheritDoc}
*
* @see #collectionEnabled()
* @see #cleaningEnabled()
*/
@Override @Override
public String[] expirationMessages() { public String[] expirationMessages() {
return new String[] { return new String[] {
"The agent will stop collecting cluster and indices metrics", "The agent will stop collecting cluster and indices metrics",
"The agent will stop to automatically clean up indices older than [xpack.monitoring.history.duration]", "The agent will stop automatically cleaning indices older than [xpack.monitoring.history.duration]",
}; };
} }
@ -58,21 +72,47 @@ public class MarvelLicensee extends AbstractLicenseeComponent<MarvelLicensee> im
return Strings.EMPTY_ARRAY; return Strings.EMPTY_ARRAY;
} }
/**
* Determine if the index cleaning service is enabled.
* <p>
* Collection is only disabled <em>automatically</em> when the license expires/becomes invalid. Collection <em>can</em> be disabled
* explicitly by the user, although that's generally a temporary solution to unrelated issues (e.g., initial setup when the monitoring
* cluster doesn't actually exist).
*
* @return {@code true} as long as the license is valid. Otherwise {@code false}.
*/
public boolean collectionEnabled() { public boolean collectionEnabled() {
// when checking multiple parts of the status, we should get a local reference to the status object since it is // note: status is volatile, so don't do multiple checks without a local ref
// volatile and can change between check statements...
Status status = this.status; Status status = this.status;
return status.getMode() != License.OperationMode.NONE && return status.getMode() != License.OperationMode.NONE && status.getLicenseState() != LicenseState.DISABLED;
status.getLicenseState() != LicenseState.DISABLED;
} }
/**
* Determine if the index cleaning service is enabled.
* <p>
* Index cleaning is only disabled when the license expires/becomes invalid.
*
* @return {@code true} as long as the license is valid. Otherwise {@code false}.
*/
public boolean cleaningEnabled() { public boolean cleaningEnabled() {
// note: status is volatile, so don't do multiple checks without a local ref
Status status = this.status; Status status = this.status;
return status.getMode() != License.OperationMode.NONE && return status.getMode() != License.OperationMode.NONE && status.getLicenseState() != LicenseState.DISABLED;
status.getLicenseState() != LicenseState.DISABLED;
} }
/**
* Determine if the current license allows the retention of indices to be modified.
* <p>
* Only users with the following license types can update the retention period:
* <ul>
* <li>{@link License.OperationMode#PLATINUM}</li>
* <li>{@link License.OperationMode#GOLD}</li>
* </ul>
*
* @return {@code true} if the user is allowed to modify the retention. Otherwise {@code false}.
*/
public boolean allowUpdateRetention() { public boolean allowUpdateRetention() {
// note: status is volatile, so don't do multiple checks without a local ref
Status status = this.status; Status status = this.status;
return status.getMode() == License.OperationMode.PLATINUM || status.getMode() == License.OperationMode.GOLD; return status.getMode() == License.OperationMode.PLATINUM || status.getMode() == License.OperationMode.GOLD;
} }