From 6e9e80facaff2c5ae97f669c10092680adaccff2 Mon Sep 17 00:00:00 2001 From: Alex Rudyy Date: Fri, 15 Aug 2014 00:49:26 +0000 Subject: QPID-5998: Fix HA operational logging git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1618086 13f79535-47bb-0310-9956-ffa450edef68 --- .../subjects/BDBHAVirtualHostNodeLogSubject.java | 32 +++++ .../server/logging/subjects/GroupLogSubject.java | 32 +++++ .../berkeleydb/BDBHARemoteReplicationNodeImpl.java | 49 ++++--- .../berkeleydb/BDBHAVirtualHostNodeImpl.java | 152 ++++++++++++++------- 4 files changed, 192 insertions(+), 73 deletions(-) create mode 100644 qpid/java/bdbstore/src/main/java/org/apache/qpid/server/logging/subjects/BDBHAVirtualHostNodeLogSubject.java create mode 100644 qpid/java/bdbstore/src/main/java/org/apache/qpid/server/logging/subjects/GroupLogSubject.java (limited to 'qpid/java/bdbstore/src/main') diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/logging/subjects/BDBHAVirtualHostNodeLogSubject.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/logging/subjects/BDBHAVirtualHostNodeLogSubject.java new file mode 100644 index 0000000000..a209062993 --- /dev/null +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/logging/subjects/BDBHAVirtualHostNodeLogSubject.java @@ -0,0 +1,32 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.qpid.server.logging.subjects; + + +public class BDBHAVirtualHostNodeLogSubject extends AbstractLogSubject +{ + public static final String VIRTUAL_HOST_NODE_FORMAT = "grp(/{0})/vhn(/{1})"; + + public BDBHAVirtualHostNodeLogSubject(String groupName, String nodeName) + { + setLogStringWithFormat(VIRTUAL_HOST_NODE_FORMAT, groupName, nodeName); + } +} diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/logging/subjects/GroupLogSubject.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/logging/subjects/GroupLogSubject.java new file mode 100644 index 0000000000..51fd1fc2dc --- /dev/null +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/logging/subjects/GroupLogSubject.java @@ -0,0 +1,32 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you 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.apache.qpid.server.logging.subjects; + + +public class GroupLogSubject extends AbstractLogSubject +{ + public static final String GROUP_FORMAT = "grp(/{0})"; + + public GroupLogSubject(String groupName) + { + setLogStringWithFormat(GROUP_FORMAT, groupName); + } +} diff --git a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNodeImpl.java b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNodeImpl.java index 5263f5942f..06671998ec 100644 --- a/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNodeImpl.java +++ b/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhostnode/berkeleydb/BDBHARemoteReplicationNodeImpl.java @@ -30,9 +30,14 @@ import java.util.Set; import java.util.concurrent.atomic.AtomicReference; import com.sleepycat.je.rep.MasterStateException; +import com.sleepycat.je.rep.ReplicatedEnvironment; import org.apache.log4j.Logger; import org.apache.qpid.server.configuration.IllegalConfigurationException; +import org.apache.qpid.server.logging.EventLogger; +import org.apache.qpid.server.logging.messages.HighAvailabilityMessages; +import org.apache.qpid.server.logging.subjects.BDBHAVirtualHostNodeLogSubject; +import org.apache.qpid.server.logging.subjects.GroupLogSubject; import org.apache.qpid.server.model.AbstractConfiguredObject; import org.apache.qpid.server.model.Broker; import org.apache.qpid.server.model.ConfiguredObject; @@ -40,6 +45,8 @@ import org.apache.qpid.server.model.IllegalStateTransitionException; import org.apache.qpid.server.model.ManagedAttributeField; import org.apache.qpid.server.model.State; import org.apache.qpid.server.model.StateTransition; +import org.apache.qpid.server.model.SystemConfig; +import org.apache.qpid.server.model.VirtualHostNode; import org.apache.qpid.server.security.access.Operation; import org.apache.qpid.server.store.berkeleydb.replication.ReplicatedEnvironmentFacade; @@ -53,13 +60,16 @@ public class BDBHARemoteReplicationNodeImpl extends AbstractConfiguredObject _state; private final boolean _isMonitor; private boolean _detached; + private BDBHAVirtualHostNodeLogSubject _virtualHostNodeLogSubject; + private GroupLogSubject _groupLogSubject; public BDBHARemoteReplicationNodeImpl(BDBHAVirtualHostNode virtualHostNode, Map attributes, ReplicatedEnvironmentFacade replicatedEnvironmentFacade) { @@ -92,7 +102,7 @@ public class BDBHARemoteReplicationNodeImpl extends AbstractConfiguredObject { public static final String VIRTUAL_HOST_NODE_TYPE = "BDB_HA"; + public static final String VIRTUAL_HOST_PRINCIPAL_NAME_FORMAT = "grp(/{0})/vhn(/{1})"; /** * Length of time we synchronously await the a JE mutation to complete. It is not considered an error if we exceed this timeout, although a @@ -87,6 +91,9 @@ public class BDBHAVirtualHostNodeImpl extends AbstractVirtualHostNode _environmentFacade = new AtomicReference<>(); private final AtomicReference _lastReplicatedEnvironmentState = new AtomicReference<>(ReplicatedEnvironment.State.UNKNOWN); + private BDBHAVirtualHostNodeLogSubject _virtualHostNodeLogSubject; + private GroupLogSubject _groupLogSubject; + private String _virtualHostNodePrincipalName; @ManagedAttributeField private String _storePath; @@ -267,7 +274,7 @@ public class BDBHAVirtualHostNodeImpl extends AbstractVirtualHostNode helpers = getRemoteNodeAddresses(); super.doDelete(); - getEventLogger().message(getVirtualHostNodeLogSubject(), HighAvailabilityMessages.DELETED(getName(), getGroupName())); + getEventLogger().message(getVirtualHostNodeLogSubject(), HighAvailabilityMessages.DELETED()); if (getState() == State.DELETED && !helpers.isEmpty()) { try @@ -413,10 +401,18 @@ public class BDBHAVirtualHostNodeImpl extends AbstractVirtualHostNode() + getTaskExecutor().submit(new VirtualHostNodeGroupTask() { @Override - public Void execute() + public void perform() { addRemoteReplicationNode(node); - return null; } }); } @@ -722,19 +726,18 @@ public class BDBHAVirtualHostNodeImpl extends AbstractVirtualHostNode() + getTaskExecutor().submit(new VirtualHostNodeGroupTask() { @Override - public Void execute() + public void perform() { recoverRemoteReplicationNode(node); - return null; } }); } @@ -745,19 +748,18 @@ public class BDBHAVirtualHostNodeImpl extends AbstractVirtualHostNode() + getTaskExecutor().submit(new VirtualHostNodeGroupTask() { @Override - public Void execute() + public void perform() { removeRemoteReplicationNode(node); - return null; } }); } @@ -768,12 +770,25 @@ public class BDBHAVirtualHostNodeImpl extends AbstractVirtualHostNode() + { + @Override + public Void run() + { + processNodeState(node, nodeState); + return null; + } + }); + } + + private void processNodeState(ReplicationNode node, NodeState nodeState) { BDBHARemoteReplicationNodeImpl remoteNode = getChildByName(BDBHARemoteReplicationNodeImpl.class, node.getName()); if (remoteNode != null) @@ -785,7 +800,7 @@ public class BDBHAVirtualHostNodeImpl extends AbstractVirtualHostNode() + { + @Override + public Void run() + { + processIntruderNode(node); + return null; + } + }); + } + + private void processIntruderNode(ReplicationNode node) { String hostAndPort = node.getHostName() + ":" + node.getPort(); - getEventLogger().message(getVirtualHostNodeLogSubject(), HighAvailabilityMessages.INTRUDER_DETECTED(node.getName(), hostAndPort, getGroupName())); + getEventLogger().message(getGroupLogSubject(), HighAvailabilityMessages.INTRUDER_DETECTED(node.getName(), hostAndPort)); boolean inManagementMode = getParent(Broker.class).isManagementMode(); if (inManagementMode) @@ -858,7 +885,7 @@ public class BDBHAVirtualHostNodeImpl extends AbstractVirtualHostNode nodeToAttributes(ReplicationNode replicationNode) @@ -872,4 +899,23 @@ public class BDBHAVirtualHostNodeImpl extends AbstractVirtualHostNode + { + @Override + public Void execute() + { + return Subject.doAs(SecurityManager.getSystemTaskSubject(_virtualHostNodePrincipalName), new PrivilegedAction() + { + @Override + public Void run() + { + perform(); + return null; + } + }); + } + + abstract void perform(); + } + } -- cgit v1.2.1