org.gridgain.grid.events.GridAuthenticationEvent Maven / Gradle / Ivy
/*
Copyright (C) GridGain Systems. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/* _________ _____ __________________ _____
* __ ____/___________(_)______ /__ ____/______ ____(_)_______
* _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
* / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
* \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
*/
package org.gridgain.grid.events;
import org.gridgain.grid.*;
import org.gridgain.grid.lang.*;
import org.gridgain.grid.spi.*;
import org.gridgain.grid.util.typedef.internal.*;
import java.util.*;
/**
* Grid authentication event.
*
* Grid events are used for notification about what happens within the grid. Note that by
* design GridGain keeps all events generated on the local node locally and it provides
* APIs for performing a distributed queries across multiple nodes:
*
* -
* {@link GridEvents#remoteQuery(GridPredicate, long)} -
* asynchronously querying events occurred on the nodes specified, including remote nodes.
*
* -
* {@link GridEvents#localQuery(GridPredicate)} -
* querying only local events stored on this local node.
*
* -
* {@link GridEvents#localListen(GridPredicate, int...)} -
* listening to local grid events (events from remote nodes not included).
*
*
* User can also wait for events using method {@link GridEvents#waitForLocal(GridPredicate, int...)}.
* Events and Performance
* Note that by default all events in GridGain are enabled and therefore generated and stored
* by whatever event storage SPI is configured. GridGain can and often does generate thousands events per seconds
* under the load and therefore it creates a significant additional load on the system. If these events are
* not needed by the application this load is unnecessary and leads to significant performance degradation.
*
* It is highly recommended to enable only those events that your application logic requires
* by using {@link GridConfiguration#getIncludeEventTypes()} method in GridGain configuration. Note that certain
* events are required for GridGain's internal operations and such events will still be generated but not stored by
* event storage SPI if they are disabled in GridGain configuration.
* @see GridEventType#EVT_AUTH_FAILED
* @see GridEventType#EVT_AUTH_SUCCEEDED
*/
public class GridAuthenticationEvent extends GridEventAdapter {
/** Subject type. */
private GridSecuritySubjectType subjType;
/** Subject ID. */
private byte[] subjId;
/** {@inheritDoc} */
@Override public String shortDisplay() {
return name() + ": subjType=" + subjType;
}
/**
* No-arg constructor.
*/
public GridAuthenticationEvent() {
// No-op.
}
/**
* Creates authentication event with given parameters.
*
* @param nodeId Node ID.
* @param msg Optional message.
* @param type Event type.
*/
public GridAuthenticationEvent(UUID nodeId, String msg, int type) {
super(nodeId, msg, type);
}
/**
* Creates authentication event with given parameters.
*
* @param nodeId Node ID.
* @param msg Optional message.
* @param type Event type.
* @param subjType Subject type.
* @param subjId Subject ID.
*/
public GridAuthenticationEvent(UUID nodeId, String msg, int type, GridSecuritySubjectType subjType, byte[] subjId) {
super(nodeId, msg, type);
this.subjType = subjType;
this.subjId = subjId;
}
/**
* Gets subject type that triggered the event.
*
* @return Subject type that triggered the event.
*/
public GridSecuritySubjectType subjectType() {
return subjType;
}
/**
* Gets subject ID that triggered the event.
*
* @return Subject ID that triggered the event.
*/
public byte[] subjectId() {
return subjId;
}
/**
* Sets subject type that triggered the event.
*
* @param subjType Subject type to set.
*/
public void subjectType(GridSecuritySubjectType subjType) {
this.subjType = subjType;
}
/**
* Sets subject ID that triggered the event.
*
* @param subjId Subject ID to set.
*/
public void subjectId(byte[] subjId) {
this.subjId = subjId;
}
/** {@inheritDoc} */
@Override public String toString() {
return S.toString(GridAuthenticationEvent.class, this,
"nodeId8", U.id8(nodeId()),
"msg", message(),
"type", name(),
"tstamp", timestamp());
}
}