Author: gdusbabek
Date: Fri Nov 19 16:26:16 2010
New Revision: 1036922
URL: http://svn.apache.org/viewvc?rev=1036922&view=rev
Log:
resolve circular initializer dependency deadlock. patch by Erik Onnen and Gary
Dusbabek, reviewed by Jonathan Ellis. CASSANDRA-1756
Added:
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/service/InitClientTest.java
Modified:
cassandra/branches/cassandra-0.7/CHANGES.txt
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageService.java
cassandra/branches/cassandra-0.7/test/conf/cassandra.yaml
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/locator/DynamicEndpointSnitchTest.java
Modified: cassandra/branches/cassandra-0.7/CHANGES.txt
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/CHANGES.txt?rev=1036922&r1=1036921&r2=1036922&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/CHANGES.txt (original)
+++ cassandra/branches/cassandra-0.7/CHANGES.txt Fri Nov 19 16:26:16 2010
@@ -41,6 +41,7 @@ dev
* fix sstableimport regression (CASSANDRA-1753)
* fix for bootstrap when no non-system tables are defined (CASSANDRA-1732)
* handle replica unavailability in index scan (CASSANDRA-1755)
+ * fix service initialization order deadlock (CASSANDRA-1756)
0.7.0-beta3
Modified:
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java?rev=1036922&r1=1036921&r2=1036922&view=diff
==============================================================================
---
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
(original)
+++
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/locator/DynamicEndpointSnitch.java
Fri Nov 19 16:26:16 2010
@@ -77,7 +77,7 @@ public class DynamicEndpointSnitch exten
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
try
{
- mbs.registerMBean(this, new
ObjectName("org.apache.cassandra.db:type=DynamicEndpointSnitch"));
+ mbs.registerMBean(this, new
ObjectName("org.apache.cassandra.db:type=DynamicEndpointSnitch,instance="+hashCode()));
}
catch (Exception e)
{
@@ -178,6 +178,8 @@ public class DynamicEndpointSnitch exten
private void updateScores() // this is expensive
{
+ if (!StorageService.instance.isInitialized())
+ return;
if (!registered)
{
ILatencyPublisher handler =
(ILatencyPublisher)MessagingService.instance.getVerbHandler(StorageService.Verb.REQUEST_RESPONSE);
Modified:
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageService.java
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageService.java?rev=1036922&r1=1036921&r2=1036922&view=diff
==============================================================================
---
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageService.java
(original)
+++
cassandra/branches/cassandra-0.7/src/java/org/apache/cassandra/service/StorageService.java
Fri Nov 19 16:26:16 2010
@@ -196,11 +196,11 @@ public class StorageService implements I
}};
+ public static final RetryingScheduledThreadPoolExecutor scheduledTasks =
new RetryingScheduledThreadPoolExecutor("ScheduledTasks");
+
private static IPartitioner partitioner_ =
DatabaseDescriptor.getPartitioner();
public static VersionedValue.VersionedValueFactory valueFactory = new
VersionedValue.VersionedValueFactory(partitioner_);
-
- public static RetryingScheduledThreadPoolExecutor scheduledTasks = new
RetryingScheduledThreadPoolExecutor("ScheduledTasks");
-
+
public static final StorageService instance = new StorageService();
public static IPartitioner getPartitioner() {
@@ -309,6 +309,11 @@ public class StorageService implements I
MessagingService.shutdown();
StageManager.shutdownNow();
}
+
+ public boolean isInitialized()
+ {
+ return initialized;
+ }
public synchronized void initClient() throws IOException
{
Modified: cassandra/branches/cassandra-0.7/test/conf/cassandra.yaml
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/conf/cassandra.yaml?rev=1036922&r1=1036921&r2=1036922&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7/test/conf/cassandra.yaml (original)
+++ cassandra/branches/cassandra-0.7/test/conf/cassandra.yaml Fri Nov 19
16:26:16 2010
@@ -21,6 +21,7 @@ disk_access_mode: mmap
seeds:
- 127.0.0.2
endpoint_snitch: org.apache.cassandra.locator.SimpleSnitch
+dynamic_snitch: true
request_scheduler: org.apache.cassandra.scheduler.RoundRobinScheduler
request_scheduler_id: keyspace
keyspaces:
Modified:
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/locator/DynamicEndpointSnitchTest.java
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/locator/DynamicEndpointSnitchTest.java?rev=1036922&r1=1036921&r2=1036922&view=diff
==============================================================================
---
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/locator/DynamicEndpointSnitchTest.java
(original)
+++
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/locator/DynamicEndpointSnitchTest.java
Fri Nov 19 16:26:16 2010
@@ -19,10 +19,11 @@
package org.apache.cassandra.locator;
+import java.io.IOException;
import java.net.InetAddress;
-import java.net.UnknownHostException;
import java.util.ArrayList;
+import org.apache.cassandra.service.StorageService;
import org.junit.Test;
import org.apache.cassandra.utils.FBUtilities;
@@ -30,8 +31,10 @@ import org.apache.cassandra.utils.FBUtil
public class DynamicEndpointSnitchTest
{
@Test
- public void testSnitch() throws UnknownHostException, InterruptedException
+ public void testSnitch() throws InterruptedException, IOException
{
+ // do this because SS needs to be initialized before DES can work
properly.
+ StorageService.instance.initClient();
int sleeptime = 150;
DynamicEndpointSnitch dsnitch = new DynamicEndpointSnitch(new
SimpleSnitch());
InetAddress self = FBUtilities.getLocalAddress();
Added:
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/service/InitClientTest.java
URL:
http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/service/InitClientTest.java?rev=1036922&view=auto
==============================================================================
---
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/service/InitClientTest.java
(added)
+++
cassandra/branches/cassandra-0.7/test/unit/org/apache/cassandra/service/InitClientTest.java
Fri Nov 19 16:26:16 2010
@@ -0,0 +1,37 @@
+package org.apache.cassandra.service;
+
+import org.junit.Test;
+
+import java.io.IOException;
+
+/**
+ * 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.
+ */
+
+
+public class InitClientTest // extends CleanupHelper
+{
+ @Test
+ public void testInitClientStartup()
+ {
+ try {
+ StorageService.instance.initClient();
+ } catch (IOException ex) {
+ throw new AssertionError(ex.getMessage());
+ }
+ }
+}