Search in sources :

Example 61 with BeforeClass

use of org.junit.BeforeClass in project cassandra by apache.

the class AbstractPendingRepairTest method setupClass.

@BeforeClass
public static void setupClass() {
    SchemaLoader.prepareServer();
    ARS = ActiveRepairService.instance;
    LocalSessionAccessor.startup();
    // cutoff messaging service
    MessagingService.instance().addMessageSink(new IMessageSink() {

        public boolean allowOutgoingMessage(MessageOut message, int id, InetAddress to) {
            return false;
        }

        public boolean allowIncomingMessage(MessageIn message, int id) {
            return false;
        }
    });
}
Also used : MessageIn(org.apache.cassandra.net.MessageIn) IMessageSink(org.apache.cassandra.net.IMessageSink) MessageOut(org.apache.cassandra.net.MessageOut) InetAddress(java.net.InetAddress) BeforeClass(org.junit.BeforeClass)

Example 62 with BeforeClass

use of org.junit.BeforeClass in project cassandra by apache.

the class VerifyTest method defineSchema.

@BeforeClass
public static void defineSchema() throws ConfigurationException {
    CompressionParams compressionParameters = CompressionParams.snappy(32768);
    loadSchema();
    createKeyspace(KEYSPACE, KeyspaceParams.simple(1), standardCFMD(KEYSPACE, CF).compression(compressionParameters), standardCFMD(KEYSPACE, CF2).compression(compressionParameters), standardCFMD(KEYSPACE, CF3), standardCFMD(KEYSPACE, CF4), standardCFMD(KEYSPACE, CORRUPT_CF), standardCFMD(KEYSPACE, CORRUPT_CF2), counterCFMD(KEYSPACE, COUNTER_CF).compression(compressionParameters), counterCFMD(KEYSPACE, COUNTER_CF2).compression(compressionParameters), counterCFMD(KEYSPACE, COUNTER_CF3), counterCFMD(KEYSPACE, COUNTER_CF4), counterCFMD(KEYSPACE, CORRUPTCOUNTER_CF), counterCFMD(KEYSPACE, CORRUPTCOUNTER_CF2), standardCFMD(KEYSPACE, CF_UUID, 0, UUIDType.instance));
}
Also used : CompressionParams(org.apache.cassandra.schema.CompressionParams) BeforeClass(org.junit.BeforeClass)

Example 63 with BeforeClass

use of org.junit.BeforeClass in project cassandra by apache.

the class SSTableCorruptionDetectionTest method setUp.

@BeforeClass
public static void setUp() {
    TableMetadata.Builder cfm = TableMetadata.builder(keyspace, table).addPartitionKeyColumn("pk", AsciiType.instance).addClusteringColumn("ck1", AsciiType.instance).addClusteringColumn("ck2", AsciiType.instance).addRegularColumn("reg1", BytesType.instance).addRegularColumn("reg2", BytesType.instance).compression(CompressionParams.noCompression());
    SchemaLoader.createKeyspace(keyspace, KeyspaceParams.simple(1), cfm);
    cfs = Keyspace.open(keyspace).getColumnFamilyStore(table);
    cfs.disableAutoCompaction();
    maxValueSize = DatabaseDescriptor.getMaxValueSize();
    DatabaseDescriptor.setMaxValueSize(1024 * 1024);
    long seed = System.nanoTime();
    logger.info("Seed {}", seed);
    random = new Random(seed);
    truncate(cfs);
    File dir = cfs.getDirectories().getDirectoryForNewSSTables();
    txn = LifecycleTransaction.offline(OperationType.WRITE);
    // Setting up/writing large values is an expensive operation, we only want to do it once per run
    writer = getWriter(cfs, dir, txn);
    for (int i = 0; i < numberOfPks; i++) {
        UpdateBuilder builder = UpdateBuilder.create(cfs.metadata(), String.format("pkvalue_%07d", i)).withTimestamp(1);
        byte[] reg1 = new byte[valueSize];
        random.nextBytes(reg1);
        byte[] reg2 = new byte[valueSize];
        random.nextBytes(reg2);
        builder.newRow("clustering_" + i, "clustering_" + (i + 1)).add("reg1", ByteBuffer.wrap(reg1)).add("reg2", ByteBuffer.wrap(reg2));
        writer.append(builder.build().unfilteredIterator());
    }
    cfs.forceBlockingFlush();
    ssTableReader = writer.finish(true);
    txn.update(ssTableReader, false);
    LifecycleTransaction.waitForDeletions();
}
Also used : RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) BeforeClass(org.junit.BeforeClass)

Example 64 with BeforeClass

use of org.junit.BeforeClass in project jstorm by alibaba.

the class ZooKeeperDataViewTest method init.

@BeforeClass
public static void init() {
    String CONFIG_PATH = System.getProperty("user.home") + CONFIG_FILE;
    File file = new File(CONFIG_PATH);
    if (file.exists() == false) {
        SKIP = true;
        return;
    }
    try {
        zkobj = new Zookeeper();
        System.getProperties().setProperty("storm.conf.file", CONFIG_PATH);
        Map conf = Utils.readStormConfig();
        zk = zkobj.mkClient(conf, (List<String>) conf.get(Config.STORM_ZOOKEEPER_SERVERS), conf.get(Config.STORM_ZOOKEEPER_PORT), (String) conf.get(Config.STORM_ZOOKEEPER_ROOT));
        gson = new GsonBuilder().setPrettyPrinting().create();
    } catch (Throwable e) {
        e.printStackTrace();
        SKIP = true;
    }
}
Also used : GsonBuilder(com.google.gson.GsonBuilder) Zookeeper(com.alibaba.jstorm.zk.Zookeeper) ArrayList(java.util.ArrayList) List(java.util.List) File(java.io.File) Map(java.util.Map) BeforeClass(org.junit.BeforeClass)

Example 65 with BeforeClass

use of org.junit.BeforeClass in project cassandra by apache.

the class BatchMetricsTest method setup.

@BeforeClass()
public static void setup() throws ConfigurationException, IOException {
    Schema.instance.clear();
    cassandra = new EmbeddedCassandraService();
    cassandra.start();
    cluster = Cluster.builder().addContactPoint("127.0.0.1").withPort(DatabaseDescriptor.getNativeTransportPort()).build();
    session = cluster.connect();
    session.execute("CREATE KEYSPACE IF NOT EXISTS " + KEYSPACE + " WITH replication = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };");
    session.execute("USE " + KEYSPACE);
    session.execute("CREATE TABLE IF NOT EXISTS " + TABLE + " (id int PRIMARY KEY, val text);");
    ps = session.prepare("INSERT INTO " + KEYSPACE + '.' + TABLE + " (id, val) VALUES (?, ?);");
}
Also used : EmbeddedCassandraService(org.apache.cassandra.service.EmbeddedCassandraService) BeforeClass(org.junit.BeforeClass)

Aggregations

BeforeClass (org.junit.BeforeClass)2813 File (java.io.File)388 Configuration (org.apache.hadoop.conf.Configuration)287 IOException (java.io.IOException)128 Connection (java.sql.Connection)126 Properties (java.util.Properties)108 Reader (java.io.Reader)99 SqlSessionFactoryBuilder (org.apache.ibatis.session.SqlSessionFactoryBuilder)98 Provisioning (com.zimbra.cs.account.Provisioning)93 ScriptRunner (org.apache.ibatis.jdbc.ScriptRunner)91 HiveConf (org.apache.hadoop.hive.conf.HiveConf)86 MockProvisioning (com.zimbra.cs.account.MockProvisioning)77 Path (org.apache.hadoop.fs.Path)75 URI (java.net.URI)73 HashMap (java.util.HashMap)70 URL (java.net.URL)63 SqlSession (org.apache.ibatis.session.SqlSession)62 MiniDFSCluster (org.apache.hadoop.hdfs.MiniDFSCluster)61 Injector (com.google.inject.Injector)57 CConfiguration (co.cask.cdap.common.conf.CConfiguration)56