mirror of https://github.com/apache/druid.git
added deleted classes back
This commit is contained in:
parent
01f2b3482c
commit
a6016d70fc
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Druid - a distributed column store.
|
||||
* Copyright (C) 2012, 2013 Metamarkets Group Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package io.druid.metadata;
|
||||
|
||||
/**
|
||||
*/
|
||||
public interface MetadataStorageConnector
|
||||
{
|
||||
public Void insertOrUpdate(
|
||||
final String tableName,
|
||||
final String keyColumn,
|
||||
final String valueColumn,
|
||||
final String key,
|
||||
final byte[] value
|
||||
) throws Exception;
|
||||
|
||||
|
||||
public byte[] lookup(
|
||||
final String tableName,
|
||||
final String keyColumn,
|
||||
final String valueColumn,
|
||||
final String key
|
||||
);
|
||||
|
||||
public void createSegmentTable();
|
||||
|
||||
public void createRulesTable();
|
||||
|
||||
public void createConfigTable();
|
||||
|
||||
public void createTaskTables();
|
||||
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
* Druid - a distributed column store.
|
||||
* Copyright (C) 2012, 2013 Metamarkets Group Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package io.druid.metadata;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class MetadataStorageConnectorConfig
|
||||
{
|
||||
@JsonProperty
|
||||
private boolean createTables = true;
|
||||
|
||||
@JsonProperty
|
||||
private String connectURI = null;
|
||||
|
||||
@JsonProperty
|
||||
private String user = null;
|
||||
|
||||
@JsonProperty
|
||||
private String password = null;
|
||||
|
||||
@JsonProperty
|
||||
private boolean useValidationQuery = false;
|
||||
|
||||
@JsonProperty
|
||||
private String validationQuery = "SELECT 1";
|
||||
|
||||
public boolean isCreateTables()
|
||||
{
|
||||
return createTables;
|
||||
}
|
||||
|
||||
public String getConnectURI()
|
||||
{
|
||||
return connectURI;
|
||||
}
|
||||
|
||||
public String getUser()
|
||||
{
|
||||
return user;
|
||||
}
|
||||
|
||||
public String getPassword()
|
||||
{
|
||||
return password;
|
||||
}
|
||||
|
||||
public boolean isUseValidationQuery()
|
||||
{
|
||||
return useValidationQuery;
|
||||
}
|
||||
|
||||
public String getValidationQuery() {
|
||||
return validationQuery;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "DbConnectorConfig{" +
|
||||
"createTables=" + createTables +
|
||||
", connectURI='" + connectURI + '\'' +
|
||||
", user='" + user + '\'' +
|
||||
", password=****" +
|
||||
", useValidationQuery=" + useValidationQuery +
|
||||
", validationQuery='" + validationQuery + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
|
@ -0,0 +1,123 @@
|
|||
/*
|
||||
* Druid - a distributed column store.
|
||||
* Copyright (C) 2012, 2013 Metamarkets Group Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
package io.druid.metadata;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonCreator;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class MetadataStorageTablesConfig
|
||||
{
|
||||
public static MetadataStorageTablesConfig fromBase(String base)
|
||||
{
|
||||
return new MetadataStorageTablesConfig(base, null, null, null, null, null, null);
|
||||
}
|
||||
|
||||
private static String defaultBase = "druid";
|
||||
|
||||
@JsonProperty("base")
|
||||
private final String base;
|
||||
|
||||
@JsonProperty("segments")
|
||||
private final String segmentsTable;
|
||||
|
||||
@JsonProperty("rules")
|
||||
private final String rulesTable;
|
||||
|
||||
@JsonProperty("config")
|
||||
private final String configTable;
|
||||
|
||||
@JsonProperty("tasks")
|
||||
private final String tasksTable;
|
||||
|
||||
@JsonProperty("taskLog")
|
||||
private final String taskLogTable;
|
||||
|
||||
@JsonProperty("taskLock")
|
||||
private final String taskLockTable;
|
||||
|
||||
@JsonCreator
|
||||
public MetadataStorageTablesConfig(
|
||||
@JsonProperty("base") String base,
|
||||
@JsonProperty("segments") String segmentsTable,
|
||||
@JsonProperty("rules") String rulesTable,
|
||||
@JsonProperty("config") String configTable,
|
||||
@JsonProperty("tasks") String tasksTable,
|
||||
@JsonProperty("taskLog") String taskLogTable,
|
||||
@JsonProperty("taskLock") String taskLockTable
|
||||
)
|
||||
{
|
||||
this.base = (base == null) ? defaultBase : base;
|
||||
this.segmentsTable = makeTableName(segmentsTable, "segments");
|
||||
this.rulesTable = makeTableName(rulesTable, "rules");
|
||||
this.configTable = makeTableName(configTable, "config");
|
||||
this.tasksTable = makeTableName(tasksTable, "tasks");
|
||||
this.taskLogTable = makeTableName(taskLogTable, "tasklogs");
|
||||
this.taskLockTable = makeTableName(taskLockTable, "tasklocks");
|
||||
}
|
||||
|
||||
private String makeTableName(String explicitTableName, String defaultSuffix)
|
||||
{
|
||||
if (explicitTableName == null) {
|
||||
if (base == null) {
|
||||
return null;
|
||||
}
|
||||
return String.format("%s_%s", base, defaultSuffix);
|
||||
}
|
||||
|
||||
return explicitTableName;
|
||||
}
|
||||
|
||||
public String getBase()
|
||||
{
|
||||
return base;
|
||||
}
|
||||
|
||||
public String getSegmentsTable()
|
||||
{
|
||||
return segmentsTable;
|
||||
}
|
||||
|
||||
public String getRulesTable()
|
||||
{
|
||||
return rulesTable;
|
||||
}
|
||||
|
||||
public String getConfigTable()
|
||||
{
|
||||
return configTable;
|
||||
}
|
||||
|
||||
public String getTasksTable()
|
||||
{
|
||||
return tasksTable;
|
||||
}
|
||||
|
||||
public String getTaskLogTable()
|
||||
{
|
||||
return taskLogTable;
|
||||
}
|
||||
|
||||
public String getTaskLockTable()
|
||||
{
|
||||
return taskLockTable;
|
||||
}
|
||||
}
|
|
@ -22,6 +22,9 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||
import com.google.common.base.Suppliers;
|
||||
import com.google.common.base.Throwables;
|
||||
import io.druid.jackson.DefaultObjectMapper;
|
||||
import io.druid.metadata.DerbyConnector;
|
||||
import io.druid.metadata.MetadataStorageConnectorConfig;
|
||||
import io.druid.metadata.MetadataStorageTablesConfig;
|
||||
import junit.framework.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
@ -80,7 +83,7 @@ public class SQLMetadataConnectorTest
|
|||
public Void withHandle(Handle handle) throws Exception
|
||||
{
|
||||
for(String table : tables) {
|
||||
Assert.assertTrue(String.format("table $s was not created!", table), connector.tableExists(handle, table));
|
||||
Assert.assertTrue(String.format("table $s was not created!", table), tableExists(handle, table));
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -167,4 +170,11 @@ public class SQLMetadataConnectorTest
|
|||
}
|
||||
}
|
||||
|
||||
private boolean tableExists(Handle handle, String tableName)
|
||||
{
|
||||
return !handle.createQuery("select * from SYS.SYSTABLES where tablename = :tableName")
|
||||
.bind("tableName", tableName.toUpperCase())
|
||||
.list()
|
||||
.isEmpty();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue