I don't know what I did, but suddenly NetBeans started to complain that some of my classes are duplicate?
To fix this issue, close NetBeans, delete NetBeans cache, start NetBeans again.
Location of the NetBeans cache is in
C:\Users\<UserName>\AppData\Local\NetBeans\Cache
References:
NetBeans 7.0 Duplicate class error message
How to clear the Cache in NetBeans
Thursday, May 29, 2014
Tuesday, May 27, 2014
How to find a file containing particular text in Linux
grep -r "text string to search” directory-path
See more at: http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/
See more at: http://www.cyberciti.biz/faq/howto-search-find-file-for-text-string/
How to create remote git repo from local project
1. create files/projects/etc.
2. cd into the directory and run
git init
3. add all of your files into git
git add *
4. commit it
git commit -m "Initial commit"
5. for kicks, run following command to see if you have any attached remote repos. you should not see anything
git remote
< see below "On your remote server" section >
6. Attach remote repo
git remote add origin ssh://user@ip.add.re.ss:22/opt/git_repos/foo-project.git
7. if you mess up, run
git remote remove origin
8. now run #5 command and you should see origin there
9. now push your local changes to repo for everyone to see
git push -u origin master
10. after that, you can just call
git push
On your remote server
a. sudo su -
b. cd <path_to_git_repos>
c. mkdir foo-project.git
d. cd foo-project.git
e. git init --shared=777 --bare
if you wont specify --shared=777 you wont be able to write to it due to permission issues. If you are stuck on Writing object part during your git push, that's the reason.
Reference:
http://qugstart.com/blog/ruby-and-rails/create-a-new-git-remote-repository-from-some-local-files-or-local-git-repository/
2. cd into the directory and run
git init
3. add all of your files into git
git add *
4. commit it
git commit -m "Initial commit"
5. for kicks, run following command to see if you have any attached remote repos. you should not see anything
git remote
< see below "On your remote server" section >
6. Attach remote repo
git remote add origin ssh://user@ip.add.re.ss:22/opt/git_repos/foo-project.git
7. if you mess up, run
git remote remove origin
8. now run #5 command and you should see origin there
9. now push your local changes to repo for everyone to see
git push -u origin master
10. after that, you can just call
git push
On your remote server
a. sudo su -
b. cd <path_to_git_repos>
c. mkdir foo-project.git
d. cd foo-project.git
e. git init --shared=777 --bare
if you wont specify --shared=777 you wont be able to write to it due to permission issues. If you are stuck on Writing object part during your git push, that's the reason.
Reference:
http://qugstart.com/blog/ruby-and-rails/create-a-new-git-remote-repository-from-some-local-files-or-local-git-repository/
Sunday, May 18, 2014
Apache Accumulo rFile Generation and Import
I wrote a very quick project to demonstrate how to generate Apache Accumulo rFile in HDFS in a location of your choice and then upload it into Apache Accumulo of your choice. Some configuration will be required. The project is still work in progress... but it will give you what you need if you are looking how to generate Accumulo records programmatically, store them in HDFS and later import them into your Accumulo instance.
Source code: https://github.com/krinkere/rFileGenerator
Source code: https://github.com/krinkere/rFileGenerator
Monday, April 28, 2014
How to pass parameters to your webstart?
Add properties in the JNLP file itself, like so
<resources>
and then call it in your code, like so
System.getProperty("prop1");
<resources>
<j2se version="1.7+" />
...
...
<property name="prop1" value="value1"/>
<property name="prop2" value="value2"/>
</resources>and then call it in your code, like so
System.getProperty("prop1");
Where am I?
While calling something like
FileInputStream stream = new FileInputStream("myfile.properties");
you might see Filenotfound exception... But it used to work before, you might say. Well, it probably did before you called this method from a different directory. Use following statement to get user's current working directory.
System.getProperty("user.dir")
FileInputStream stream = new FileInputStream("myfile.properties");
you might see Filenotfound exception... But it used to work before, you might say. Well, it probably did before you called this method from a different directory. Use following statement to get user's current working directory.
System.getProperty("user.dir")
Sunday, April 13, 2014
Connecting to the Accumulo using Java
Now that our Accumulo is set up, let’s connect to it through Java App so we can create our first table and write some data into it.
(I am going to assume that you have maven installed on your machine… If not, see this)
Create simple maven project.
mvn archetype:generate -DgroupId=org.mytest.accexample -DartifactId=simple -Dpackage=org.mytest.accexample -Dversion=1.0-SNAPSHOT
Accept all defaults.
Since we will be connecting to Accumulo, it comes to no surprise that we would need jars to support Accumulo, Zookeeper and Hadoop. So add this to your pom.xml file
<dependency>
<groupId>org.apache.accumulo</groupId>
<artifactId>accumulo-core</artifactId>
<version>1.4.4</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.5</version>
</dependency>
Now it is time to write a program to connect to our Accumulo instance and put some records in!
package org.mytest.accexample;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.BatchWriter;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.Instance;
import org.apache.accumulo.core.client.TableExistsException;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.client.ZooKeeperInstance;
import org.apache.accumulo.core.client.admin.TableOperations;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.security.ColumnVisibility;
import org.apache.hadoop.io.Text;
public class App {
public static void main(String[] args) throws AccumuloException, AccumuloSecurityException,TableNotFoundException, TableExistsException {
// Constants
String instanceName = "default";
String zooServers = ""; // Provide list of zookeeper server here. In our case, we had just one so localhost:2181 should do
String userName = ""; // Provide username
String password = ""; // Provide password
// Connect
Instance inst = new ZooKeeperInstance(instanceName,zooServers);
Connector conn = inst.getConnector(userName, password);
// Let’s create our new table
String tableName = "myTable";
TableOperations ops = conn.tableOperations();
if (ops.exists(tableName)) {
ops.delete(tableName);
}
ops.create(tableName);
// Use batch writer to write demo data
BatchWriter bw = conn.createBatchWriter(tableName,1000000, 60000, 2);
// set values
Text rowID = new Text("row1");
Text colFam = new Text("colFam");
Text colQual = new Text("colQual");
// set value
Value value = new Value("some-value".getBytes());
// create new mutation and add rowID, colFam, colQual, and value
Mutation mutation = new Mutation(rowID);
mutation.put(colFam, colQual, value);
// add the mutation to the batch writer
bw.addMutation(mutation);
// close the batch writer
bw.close();
}
}
Run it… Congratulations you just wrote your first record into Accumulo! Now let’s view it in the table just to make sure it is indeed there.
Let’s take a different approach and access Accumulo through bash shell.
$ACCUMULO_HOME/bin/accumulo shell -u [username]
Then provide your password.
Type ‘tables’ to see a list of available tables. You should see myTable in the list.
Type ‘table myTable’ to access it. Now execute simple scan to view your records.
root@default myTable> table myTable
root@default myTable> scan
row1 colFam:colQual [] some-value
Success!
Now, what’s that security level stuff in Accumulo everyone is talking about? Well, it is a way to ensure that only rows that fit your authorization will be shown to you. That’s it in the nutshell, for more in details explanation please refer to this.
Let’s add this to our Java App Accumulo writer. Add ColumnVisibility variable and add it to the mutation object. Here is the complete example with changes highlighted in red:
package org.mytest.accexample;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.BatchWriter;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.Instance;
import org.apache.accumulo.core.client.TableExistsException;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.client.ZooKeeperInstance;
import org.apache.accumulo.core.client.admin.TableOperations;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.security.ColumnVisibility;
import org.apache.hadoop.io.Text;
public class App {
public static void main(String[] args) throws AccumuloException, AccumuloSecurityException,TableNotFoundException, TableExistsException {
// Constants
String instanceName = "default";
String zooServers = "";
String userName = "";
String password = "";
// Connect
Instance inst = new ZooKeeperInstance(instanceName,zooServers);
Connector conn = inst.getConnector(userName, password);
String tableName = "myTable";
TableOperations ops = conn.tableOperations();
if (ops.exists(tableName)) {
ops.delete(tableName);
}
ops.create(tableName);
// Use batch writer to write demo data
BatchWriter bw = conn.createBatchWriter(tableName,1000000, 60000, 2);
// set values
Text rowID = new Text("row1");
Text colFam = new Text("colFam");
Text colQual = new Text("colQual");
// set visibility
ColumnVisibility colVis = new ColumnVisibility("public");
// set value
Value value = new Value("some-value".getBytes());
// create new mutation and add rowID, colFam, colQual, and value
Mutation mutation = new Mutation(rowID);
mutation.put(colFam, colQual, colVis, value);
// add the mutation to the batch writer
bw.addMutation(mutation);
// close the batch writer
bw.close();
}
}
Run the example again… Now log into Accumulo shell and scan the myTable. You won’t see anything! What?
Well, you just wrote a record that would be shown only to users with authorization to view ‘public’ rows. What can you view right now for your user? Run ‘getauths’ command in the shell to find out.
‘public’ auth was probably not in the list, hence inability to see the freshly inserted record.
Let’s add ‘public’ to the list of authorizations. Run following command from the bash
root@default myTable> setauths -s public
Now run the scan and you should be able to see the row. Notice ‘public’ in square brackets
root@default myTable> scan
row1 colFam:colQual [public] some-value
In summary, we were able to write a java client that would communicate with Accumulo instance and would insert a record. We used Accumulo bash shell to view the record. We also briefly touched on cell level security.
Reference:
1. Accumulo Shell Command Guide.
2. Accumulo Visibility.
(I am going to assume that you have maven installed on your machine… If not, see this)
Create simple maven project.
mvn archetype:generate -DgroupId=org.mytest.accexample -DartifactId=simple -Dpackage=org.mytest.accexample -Dversion=1.0-SNAPSHOT
Accept all defaults.
Since we will be connecting to Accumulo, it comes to no surprise that we would need jars to support Accumulo, Zookeeper and Hadoop. So add this to your pom.xml file
<dependency>
<groupId>org.apache.accumulo</groupId>
<artifactId>accumulo-core</artifactId>
<version>1.4.4</version>
</dependency>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-core</artifactId>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.5</version>
</dependency>
Now it is time to write a program to connect to our Accumulo instance and put some records in!
package org.mytest.accexample;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.BatchWriter;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.Instance;
import org.apache.accumulo.core.client.TableExistsException;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.client.ZooKeeperInstance;
import org.apache.accumulo.core.client.admin.TableOperations;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.security.ColumnVisibility;
import org.apache.hadoop.io.Text;
public class App {
public static void main(String[] args) throws AccumuloException, AccumuloSecurityException,TableNotFoundException, TableExistsException {
// Constants
String instanceName = "default";
String zooServers = ""; // Provide list of zookeeper server here. In our case, we had just one so localhost:2181 should do
String userName = ""; // Provide username
String password = ""; // Provide password
// Connect
Instance inst = new ZooKeeperInstance(instanceName,zooServers);
Connector conn = inst.getConnector(userName, password);
// Let’s create our new table
String tableName = "myTable";
TableOperations ops = conn.tableOperations();
if (ops.exists(tableName)) {
ops.delete(tableName);
}
ops.create(tableName);
// Use batch writer to write demo data
BatchWriter bw = conn.createBatchWriter(tableName,1000000, 60000, 2);
// set values
Text rowID = new Text("row1");
Text colFam = new Text("colFam");
Text colQual = new Text("colQual");
// set value
Value value = new Value("some-value".getBytes());
// create new mutation and add rowID, colFam, colQual, and value
Mutation mutation = new Mutation(rowID);
mutation.put(colFam, colQual, value);
// add the mutation to the batch writer
bw.addMutation(mutation);
// close the batch writer
bw.close();
}
}
Run it… Congratulations you just wrote your first record into Accumulo! Now let’s view it in the table just to make sure it is indeed there.
Let’s take a different approach and access Accumulo through bash shell.
$ACCUMULO_HOME/bin/accumulo shell -u [username]
Then provide your password.
Type ‘tables’ to see a list of available tables. You should see myTable in the list.
Type ‘table myTable’ to access it. Now execute simple scan to view your records.
root@default myTable> table myTable
root@default myTable> scan
row1 colFam:colQual [] some-value
Success!
Now, what’s that security level stuff in Accumulo everyone is talking about? Well, it is a way to ensure that only rows that fit your authorization will be shown to you. That’s it in the nutshell, for more in details explanation please refer to this.
Let’s add this to our Java App Accumulo writer. Add ColumnVisibility variable and add it to the mutation object. Here is the complete example with changes highlighted in red:
package org.mytest.accexample;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.BatchWriter;
import org.apache.accumulo.core.client.Connector;
import org.apache.accumulo.core.client.Instance;
import org.apache.accumulo.core.client.TableExistsException;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.client.ZooKeeperInstance;
import org.apache.accumulo.core.client.admin.TableOperations;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.security.ColumnVisibility;
import org.apache.hadoop.io.Text;
public class App {
public static void main(String[] args) throws AccumuloException, AccumuloSecurityException,TableNotFoundException, TableExistsException {
// Constants
String instanceName = "default";
String zooServers = "";
String userName = "";
String password = "";
// Connect
Instance inst = new ZooKeeperInstance(instanceName,zooServers);
Connector conn = inst.getConnector(userName, password);
String tableName = "myTable";
TableOperations ops = conn.tableOperations();
if (ops.exists(tableName)) {
ops.delete(tableName);
}
ops.create(tableName);
// Use batch writer to write demo data
BatchWriter bw = conn.createBatchWriter(tableName,1000000, 60000, 2);
// set values
Text rowID = new Text("row1");
Text colFam = new Text("colFam");
Text colQual = new Text("colQual");
// set visibility
ColumnVisibility colVis = new ColumnVisibility("public");
// set value
Value value = new Value("some-value".getBytes());
// create new mutation and add rowID, colFam, colQual, and value
Mutation mutation = new Mutation(rowID);
mutation.put(colFam, colQual, colVis, value);
// add the mutation to the batch writer
bw.addMutation(mutation);
// close the batch writer
bw.close();
}
}
Run the example again… Now log into Accumulo shell and scan the myTable. You won’t see anything! What?
Well, you just wrote a record that would be shown only to users with authorization to view ‘public’ rows. What can you view right now for your user? Run ‘getauths’ command in the shell to find out.
‘public’ auth was probably not in the list, hence inability to see the freshly inserted record.
Let’s add ‘public’ to the list of authorizations. Run following command from the bash
root@default myTable> setauths -s public
Now run the scan and you should be able to see the row. Notice ‘public’ in square brackets
root@default myTable> scan
row1 colFam:colQual [public] some-value
In summary, we were able to write a java client that would communicate with Accumulo instance and would insert a record. We used Accumulo bash shell to view the record. We also briefly touched on cell level security.
Reference:
1. Accumulo Shell Command Guide.
2. Accumulo Visibility.
Subscribe to:
Posts (Atom)