http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/d0d25c9b/processing/src/test/java/org/apache/carbondata/lcm/locks/LocalFileLockTest.java ---------------------------------------------------------------------- diff --git a/processing/src/test/java/org/apache/carbondata/lcm/locks/LocalFileLockTest.java b/processing/src/test/java/org/apache/carbondata/lcm/locks/LocalFileLockTest.java deleted file mode 100644 index 5f7190a..0000000 --- a/processing/src/test/java/org/apache/carbondata/lcm/locks/LocalFileLockTest.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * 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. - */ -package org.apache.carbondata.lcm.locks; - -import org.apache.carbondata.core.CarbonTableIdentifier; -import org.apache.carbondata.locks.LocalFileLock; -import org.apache.carbondata.locks.LockUsage; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import org.pentaho.di.core.util.Assert; - -/** - * Test class to test the functionality of the local file locking. - * - * @author Administrator - */ -public class LocalFileLockTest { - - /** - * @throws java.lang.Exception - */ - @Before public void setUp() throws Exception { - } - - /** - * @throws java.lang.Exception - */ - @After public void tearDown() throws Exception { - } - - @Test public void testingLocalFileLockingByAcquiring2Locks() { - - CarbonTableIdentifier carbonTableIdentifier = new CarbonTableIdentifier("databaseName", "tableName", "tableId"); - LocalFileLock localLock1 = - new LocalFileLock(carbonTableIdentifier, - LockUsage.METADATA_LOCK); - Assert.assertTrue(localLock1.lock()); - LocalFileLock localLock2 = - new LocalFileLock(carbonTableIdentifier, - LockUsage.METADATA_LOCK); - Assert.assertTrue(!localLock2.lock()); - - Assert.assertTrue(localLock1.unlock()); - Assert.assertTrue(localLock2.lock()); - - } - -}
http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/d0d25c9b/processing/src/test/java/org/apache/carbondata/lcm/locks/ZooKeeperLockingTest.java ---------------------------------------------------------------------- diff --git a/processing/src/test/java/org/apache/carbondata/lcm/locks/ZooKeeperLockingTest.java b/processing/src/test/java/org/apache/carbondata/lcm/locks/ZooKeeperLockingTest.java deleted file mode 100644 index 6c21543..0000000 --- a/processing/src/test/java/org/apache/carbondata/lcm/locks/ZooKeeperLockingTest.java +++ /dev/null @@ -1,144 +0,0 @@ -/* - * 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. - */ -package org.apache.carbondata.lcm.locks; - -import mockit.NonStrictExpectations; -import org.apache.carbondata.core.CarbonTableIdentifier; -import org.apache.carbondata.core.util.CarbonProperties; -import org.apache.carbondata.locks.LockUsage; -import org.apache.carbondata.locks.ZooKeeperLocking; -import org.apache.carbondata.locks.ZookeeperInit; -import org.apache.zookeeper.server.ServerConfig; -import org.apache.zookeeper.server.ZooKeeperServerMain; -import org.apache.zookeeper.server.quorum.QuorumPeerConfig; -import org.junit.After; -import org.junit.Assert; -import org.junit.Before; -import org.junit.Test; - -import java.io.File; -import java.io.IOException; -import java.net.ServerSocket; -import java.util.Properties; - -/** - * @author Administrator - */ -public class ZooKeeperLockingTest { - - int freePort; - - /** - * @throws java.lang.Exception - */ - @Before public void setUp() throws Exception { - Properties startupProperties = new Properties(); - startupProperties.setProperty("dataDir", (new File("./target").getAbsolutePath())); - startupProperties.setProperty("dataLogDir", (new File("./target").getAbsolutePath())); - freePort = findFreePort(); - startupProperties.setProperty("clientPort", "" + freePort); - QuorumPeerConfig quorumConfiguration = new QuorumPeerConfig(); - try { - quorumConfiguration.parseProperties(startupProperties); - } catch (Exception e) { - throw new RuntimeException(e); - } - - final ZooKeeperServerMain zooKeeperServer = new ZooKeeperServerMain(); - final ServerConfig configuration = new ServerConfig(); - configuration.readFrom(quorumConfiguration); - new Thread() { - public void run() { - try { - zooKeeperServer.runFromConfig(configuration); - } catch (IOException e) { - System.out.println("ZooKeeper failure"); - } - } - }.start(); - } - - /** - * @throws java.lang.Exception - */ - @After public void tearDown() throws Exception { - } - - @Test public void testZooKeeperLockingByTryingToAcquire2Locks() - throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, - SecurityException { - - final CarbonProperties cp = CarbonProperties.getInstance(); - new NonStrictExpectations(cp) { - { - cp.getProperty("/CarbonLocks"); - result = "/carbontests"; - cp.getProperty("spark.deploy.zookeeper.url"); - result = "127.0.0.1:" + freePort; - } - }; - - ZookeeperInit zki = ZookeeperInit.getInstance("127.0.0.1:" + freePort); - - CarbonTableIdentifier tableIdentifier = new CarbonTableIdentifier("dbName", "tableName", "tableId"); - ZooKeeperLocking zkl = - new ZooKeeperLocking(tableIdentifier, - LockUsage.METADATA_LOCK); - Assert.assertTrue(zkl.lock()); - - ZooKeeperLocking zk2 = new ZooKeeperLocking( - tableIdentifier, LockUsage.METADATA_LOCK); - Assert.assertTrue(!zk2.lock()); - - Assert.assertTrue(zkl.unlock()); - Assert.assertTrue(zk2.lock()); - Assert.assertTrue(zk2.unlock()); - } - - /** - * For finding the free port available. - * - * @return - */ - private static int findFreePort() { - ServerSocket socket = null; - try { - socket = new ServerSocket(0); - socket.setReuseAddress(true); - int port = socket.getLocalPort(); - try { - socket.close(); - } catch (IOException e) { - // Ignore IOException on close() - } - return port; - } catch (Exception e) { - // Ignore - } finally { - if (socket != null) { - try { - socket.close(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - } - return 2181; - } -} http://git-wip-us.apache.org/repos/asf/incubator-carbondata/blob/d0d25c9b/processing/src/test/java/org/apache/carbondata/test/util/StoreCreator.java ---------------------------------------------------------------------- diff --git a/processing/src/test/java/org/apache/carbondata/test/util/StoreCreator.java b/processing/src/test/java/org/apache/carbondata/test/util/StoreCreator.java index 3afc0ae..a105eee 100644 --- a/processing/src/test/java/org/apache/carbondata/test/util/StoreCreator.java +++ b/processing/src/test/java/org/apache/carbondata/test/util/StoreCreator.java @@ -24,10 +24,10 @@ import org.apache.carbondata.core.cache.CacheProvider; import org.apache.carbondata.core.cache.CacheType; import org.apache.carbondata.core.cache.dictionary.Dictionary; import org.apache.carbondata.core.cache.dictionary.DictionaryColumnUniqueIdentifier; -import org.apache.carbondata.core.AbsoluteTableIdentifier; -import org.apache.carbondata.core.CarbonDataLoadSchema; -import org.apache.carbondata.core.CarbonTableIdentifier; -import org.apache.carbondata.core.ColumnIdentifier; +import org.apache.carbondata.core.metadata.AbsoluteTableIdentifier; +import org.apache.carbondata.processing.model.CarbonDataLoadSchema; +import org.apache.carbondata.core.metadata.CarbonTableIdentifier; +import org.apache.carbondata.core.metadata.ColumnIdentifier; import org.apache.carbondata.core.metadata.CarbonMetadata; import org.apache.carbondata.core.metadata.converter.SchemaConverter; import org.apache.carbondata.core.metadata.converter.ThriftWrapperSchemaConverterImpl; @@ -57,9 +57,9 @@ import org.apache.carbondata.core.writer.sortindex.CarbonDictionarySortIndexWrit import org.apache.carbondata.core.writer.sortindex.CarbonDictionarySortIndexWriterImpl; import org.apache.carbondata.core.writer.sortindex.CarbonDictionarySortInfo; import org.apache.carbondata.core.writer.sortindex.CarbonDictionarySortInfoPreparator; -import org.apache.carbondata.fileoperations.AtomicFileOperations; -import org.apache.carbondata.fileoperations.AtomicFileOperationsImpl; -import org.apache.carbondata.fileoperations.FileWriteOperation; +import org.apache.carbondata.core.atomic.AtomicFileOperations; +import org.apache.carbondata.core.atomic.AtomicFileOperationsImpl; +import org.apache.carbondata.core.atomic.FileWriteOperation; import org.apache.carbondata.processing.api.dataloader.DataLoadModel; import org.apache.carbondata.processing.api.dataloader.SchemaInfo; import org.apache.carbondata.processing.csvload.DataGraphExecuter;