You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by sj...@apache.org on 2015/01/09 14:11:52 UTC
[8/9] incubator-brooklyn git commit: Synchronise DNS objects with
specific mutexes
Synchronise DNS objects with specific mutexes
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/aedd2b22
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/aedd2b22
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/aedd2b22
Branch: refs/heads/master
Commit: aedd2b229f553a7fb301a5a745ff6573df5a3bb7
Parents: 85a12af
Author: Sam Corbett <sa...@cloudsoftcorp.com>
Authored: Fri Jan 9 12:54:41 2015 +0000
Committer: Sam Corbett <sa...@cloudsoftcorp.com>
Committed: Fri Jan 9 12:54:41 2015 +0000
----------------------------------------------------------------------
.../entity/network/bind/BindDnsServer.java | 5 +++++
.../entity/network/bind/BindDnsServerImpl.java | 18 ++++++++++++------
.../network/bind/BindDnsServerSshDriver.java | 3 ++-
3 files changed, 19 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/aedd2b22/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServer.java
----------------------------------------------------------------------
diff --git a/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServer.java b/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServer.java
index bbb2712..7928a30 100644
--- a/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServer.java
+++ b/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServer.java
@@ -148,4 +148,9 @@ public interface BindDnsServer extends SoftwareProcess {
@Effector(description="Gets the IP to hostname mappings stored in this DNS server's conf file")
public Map<String, String> getReverseMappings();
+ /**
+ * @return the predicate used to filter entities for the Bind server to manage.
+ */
+ Predicate<? super Entity> getEntityFilter();
+
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/aedd2b22/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServerImpl.java
----------------------------------------------------------------------
diff --git a/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServerImpl.java b/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServerImpl.java
index f02d71a..0b5331f 100644
--- a/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServerImpl.java
+++ b/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServerImpl.java
@@ -73,6 +73,7 @@ import brooklyn.util.text.Strings;
public class BindDnsServerImpl extends SoftwareProcessImpl implements BindDnsServer {
private static final Logger LOG = LoggerFactory.getLogger(BindDnsServerImpl.class);
+ private final Object serialMutex = new Object();
// As per RFC 952 and RFC 1123.
private static final CharMatcher DOMAIN_NAME_FIRST_CHAR_MATCHER = CharMatcher.inRange('a', 'z')
@@ -110,7 +111,9 @@ public class BindDnsServerImpl extends SoftwareProcessImpl implements BindDnsSer
setAttribute(CNAME_RECORDS, ImmutableMultimap.<String, String>of());
setAttribute(PTR_RECORDS, ImmutableMap.<String, String>of());
setAttribute(ADDRESS_MAPPINGS, ImmutableMultimap.<String, String>of());
- setAttribute(SERIAL, System.currentTimeMillis());
+ synchronized (serialMutex) {
+ setAttribute(SERIAL, System.currentTimeMillis());
+ }
}
@Override
@@ -275,12 +278,13 @@ public class BindDnsServerImpl extends SoftwareProcessImpl implements BindDnsSer
String.format("rm -f %s", temp)));
}
- // Mostly used in templates
- protected Predicate<? super Entity> getEntityFilter() {
+ @Override
+ public Predicate<? super Entity> getEntityFilter() {
return getConfig(ENTITY_FILTER);
}
+ // Mostly used in templates
public String getManagementCidr() {
return getConfig(MANAGEMENT_CIDR);
}
@@ -297,9 +301,11 @@ public class BindDnsServerImpl extends SoftwareProcessImpl implements BindDnsSer
* @return A serial number guaranteed to be valid for use in a modified domain.zone or reverse.zone file.
*/
public long getSerial() {
- long next = getAttribute(SERIAL) + 1;
- setAttribute(SERIAL, next);
- return next;
+ synchronized (serialMutex) {
+ long next = getAttribute(SERIAL) + 1;
+ setAttribute(SERIAL, next);
+ return next;
+ }
}
public Cidr getReverseLookupNetwork() {
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/aedd2b22/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServerSshDriver.java
----------------------------------------------------------------------
diff --git a/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServerSshDriver.java b/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServerSshDriver.java
index dd00cfe..983be65 100644
--- a/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServerSshDriver.java
+++ b/software/network/src/main/java/brooklyn/entity/network/bind/BindDnsServerSshDriver.java
@@ -44,6 +44,7 @@ public class BindDnsServerSshDriver extends AbstractSoftwareProcessSshDriver imp
private static final Logger LOG = LoggerFactory.getLogger(BindDnsServerSshDriver.class);
private volatile BindOsSupport osSupport;
+ private final Object osSupportMutex = new Object();
public BindDnsServerSshDriver(BindDnsServerImpl entity, SshMachineLocation machine) {
super(entity, machine);
@@ -168,7 +169,7 @@ public class BindDnsServerSshDriver extends AbstractSoftwareProcessSshDriver imp
public BindOsSupport getOsSupport() {
BindOsSupport result = osSupport;
if (result == null) {
- synchronized(this) {
+ synchronized (osSupportMutex) {
result = osSupport;
if (result == null) {
boolean yumExists = newScript("testing for yum")