Skip to content

Commit

Permalink
Merge remote-tracking branch 'metamx/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
cheddar committed Oct 24, 2013
2 parents adf6625 + 781673a commit 276a62a
Show file tree
Hide file tree
Showing 101 changed files with 4,251 additions and 2,027 deletions.
6 changes: 3 additions & 3 deletions cassandra-storage/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.metamx.druid</groupId>
<groupId>io.druid.extensions</groupId>
<artifactId>druid-cassandra-storage</artifactId>
<name>druid-cassandra-storage</name>
<description>druid-cassandra-storage</description>

<parent>
<groupId>com.metamx</groupId>
<groupId>io.druid</groupId>
<artifactId>druid</artifactId>
<version>0.6.0-SNAPSHOT</version>
<version>0.6.1-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
6 changes: 3 additions & 3 deletions common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.metamx.druid</groupId>
<groupId>io.druid</groupId>
<artifactId>druid-common</artifactId>
<name>druid-common</name>
<description>druid-common</description>

<parent>
<groupId>com.metamx</groupId>
<groupId>io.druid</groupId>
<artifactId>druid</artifactId>
<version>0.6.0-SNAPSHOT</version>
<version>0.6.1-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
40 changes: 26 additions & 14 deletions common/src/main/java/io/druid/common/config/ConfigManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.google.common.base.Throwables;
import com.google.common.collect.Maps;
import com.google.inject.Inject;
import com.metamx.common.ISE;
import com.metamx.common.concurrent.ScheduledExecutors;
import com.metamx.common.lifecycle.LifecycleStart;
import com.metamx.common.lifecycle.LifecycleStop;
Expand All @@ -38,6 +39,7 @@
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentMap;
Expand Down Expand Up @@ -76,7 +78,7 @@ public ConfigManager(IDBI dbi, Supplier<DbTablesConfig> dbTables, Supplier<Confi
final String configTable = dbTables.get().getConfigTable();

this.selectStatement = String.format("SELECT payload FROM %s WHERE name = :name", configTable);
insertStatement = String.format(
this.insertStatement = String.format(
"INSERT INTO %s (name, payload) VALUES (:name, :payload) ON DUPLICATE KEY UPDATE payload = :payload",
configTable
);
Expand Down Expand Up @@ -186,19 +188,29 @@ public byte[] lookup(final String key)
@Override
public byte[] withHandle(Handle handle) throws Exception
{
return handle.createQuery(selectStatement)
.bind("name", key)
.map(
new ResultSetMapper<byte[]>()
{
@Override
public byte[] map(int index, ResultSet r, StatementContext ctx) throws SQLException
{
return r.getBytes("payload");
}
}
)
.first();
List<byte[]> matched = handle.createQuery(selectStatement)
.bind("name", key)
.map(
new ResultSetMapper<byte[]>()
{
@Override
public byte[] map(int index, ResultSet r, StatementContext ctx)
throws SQLException
{
return r.getBytes("payload");
}
}
).list();

if (matched.isEmpty()) {
return null;
}

if (matched.size() > 1) {
throw new ISE("Error! More than one matching entry[%d] found for [%s]?!", matched.size(), key);
}

return matched.get(0);
}
}
);
Expand Down
Loading

0 comments on commit 276a62a

Please sign in to comment.