001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.kernel.cluster;
016    
017    import java.io.Serializable;
018    
019    import java.util.Arrays;
020    import java.util.Collections;
021    import java.util.List;
022    
023    /**
024     * @author Tina Tian
025     */
026    public class ClusterEvent implements Serializable {
027    
028            public static ClusterEvent depart(ClusterNode... clusterNodes) {
029                    return new ClusterEvent(
030                            ClusterEventType.DEPART, Arrays.asList(clusterNodes));
031            }
032    
033            public static ClusterEvent depart(List<ClusterNode> clusterNodes) {
034                    return new ClusterEvent(ClusterEventType.DEPART, clusterNodes);
035            }
036    
037            public static ClusterEvent join(ClusterNode... clusterNodes) {
038                    return new ClusterEvent(
039                            ClusterEventType.JOIN, Arrays.asList(clusterNodes));
040            }
041    
042            public static ClusterEvent join(List<ClusterNode> clusterNodes) {
043                    return new ClusterEvent(ClusterEventType.JOIN, clusterNodes);
044            }
045    
046            public ClusterEvent(ClusterEventType clusterEventType) {
047                    this(clusterEventType, Collections.<ClusterNode>emptyList());
048            }
049    
050            public ClusterEvent(
051                    ClusterEventType clusterEventType, List<ClusterNode> clusterNodes) {
052    
053                    _clusterEventType = clusterEventType;
054                    _clusterNodes = clusterNodes;
055            }
056    
057            public ClusterEventType getClusterEventType() {
058                    return _clusterEventType;
059            }
060    
061            public List<ClusterNode> getClusterNodes() {
062                    return _clusterNodes;
063            }
064    
065            private ClusterEventType _clusterEventType;
066            private List<ClusterNode> _clusterNodes;
067    
068    }