-
Sungchul Lee (Big Data and Block Chain Researcher)
Assistant Professor
Department of Computer Science
University of Wisconsin-Whitewater
lees at uww dot edu
-
Sungchul Lee
I was born in Seoul, Korea. I received my Ph.D. degree in computer science from the University of Nevada, Las Vegas (UNLV) in 2018. I was one of the members of the Nevada Energy-Water-Environment Nexus Project funded by NSF where I was conducting the data analysis and data security research. My research interests include big data analytics with Hadoop system, secure network protocol design, authentication and access control schemes, block chain and user behavior analysis in Smart Grid environment. I am also investigating navigation and collision avoidance algorithms for Aircraft Systems through simulations studies.I am also working on traumatic brain injury (TBI) research. I made a mobile health (mHealth) real-time system for collecting data from participants, and I have been analyzing the body balance of TBI.
Publications List
MbinetLab sensors connection (Project Setup for Android API 4.4)
https://mbientlab.com/androiddocs/latest/project_setup.htm
Create an Empty project in Android Studio.
And setting three files (AndroidManifest.xml, build.grade(project:) and build.grade(Module:app))
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.lee.mbinetsensor"> <application android:allowBackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> <service android:name="com.mbientlab.metawear.android.BtleService" /> <activity android:name=".MainActivity"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> </application> </manifest>
buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { jcenter() ivy { url "https://mbientlab.com/releases/ivyrep" layout "gradle" } } } task clean(type: Delete) { delete rootProject.buildDir }build.grade(Module:app)apply plugin: 'com.android.application' android { compileSdkVersion 26 buildToolsVersion "26.0.1" defaultConfig { applicationId "com.example.lee.mbinetsensor" minSdkVersion 19 targetSdkVersion 26 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { exclude group: 'com.android.support', module: 'support-annotations' }) compile 'com.android.support:appcompat-v7:26.+' compile 'com.android.support.constraint:constraint-layout:1.0.2' testCompile 'junit:junit:4.12' compile 'com.mbientlab:metawear:3.2.2'}Now, we can start own programming in MainActivity.java.package com.example.lee.mbinetsensor; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; import android.os.Bundle; import android.os.IBinder; import android.support.v7.app.AppCompatActivity; import android.util.Log; import com.mbientlab.metawear.android.BtleService; import com.mbientlab.metawear.module.Accelerometer; public class MainActivity extends AppCompatActivity implements ServiceConnection { private BtleService.LocalBinder serviceBinder; private Accelerometer accelerometer; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); ///< Bind the service when the activity is created getApplicationContext().bindService(new Intent(this, BtleService.class), this, Context.BIND_AUTO_CREATE); } @Override public void onDestroy() { super.onDestroy(); ///< Unbind the service when the activity is destroyed getApplicationContext().unbindService(this); } @Override public void onServiceConnected(ComponentName name, IBinder service) { ///< Typecast the binder to the service's LocalBinder class serviceBinder = (BtleService.LocalBinder) service; Log.i("Sensor","service connected"); } @Override public void onServiceDisconnected(ComponentName componentName) { } }
Merge two CSV file (outer join)
#python read csv files and merge it with outer join
import pandas as pd a= pd.read_csv("1.csv") b=pd.read_csv("2.csv") #key is for index (column name for ID) two IDmerge=a.merge(b,on=["key1","key2"],how='outer' ) #exmport csv file result.to_csv("output.csv",index=False)
Android Wear (Send message from android wear to phone)
I referenced the Data Layer Messages.
First, I start with mobile part.
build.gradle(Module:wear)
I added more depencies.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.support:wearable:2.0.0'
compile 'com.google.android.gms:play-services-wearable:11.0.4'
provided 'com.google.android.wearable:wearable:1.0.0'
//for message api, we need google service.
compile 'com.google.android.gms:play-services:11.0.4'
}
//I added the service to receive the message from wear
moblie/manifests/AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.lee.helloworld">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.BODY_SENSORS" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.wearable.standalone"
android:value="true" />
//add meta-data for google service.
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
//I added "ListenerService". you can make new service like creating new java class
//Or, Alt+Enter and create class
<service android:name=".ListenerService">
<intent-filter>
<action android:name="com.google.android.gms.wearable.BIND_LISTENER" />
</intent-filter>
</service>
</application>
</manifest>
mobile/java/ListenerService.java
import android.app.Service;
import android.content.Intent;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import com.google.android.gms.wearable.MessageEvent;
import com.google.android.gms.wearable.WearableListenerService;
public class ListenerService extends WearableListenerService {
@Override
public void onMessageReceived(MessageEvent messageEvent) {
if (messageEvent.getPath().equals("/message_path")) {
final String message = new String(messageEvent.getData());
}
else {
super.onMessageReceived(messageEvent);
}
if (messageEvent.getPath().equals("/message_path")) {
final String message = new String(messageEvent.getData());
Intent messageIntent = new Intent();
messageIntent.setAction(Intent.ACTION_SEND);
messageIntent.putExtra("message", message);
LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent);
} else {
super.onMessageReceived(messageEvent);
}
}
}
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setAmbientEnabled();
mContainerView = (BoxInsetLayout) findViewById(R.id.container);
mTextView = (TextView) findViewById(R.id.text);
mClockView = (TextView) findViewById(R.id.clock);
mGoogleApiClient=new GoogleApiClient.Builder(this).addApi(Wearable.API).
addConnectionCallbacks(this).
addOnConnectionFailedListener(this).build();
mSensorManager = ((SensorManager) getSystemService(SENSOR_SERVICE));
mGyroscopeSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
// 0:x 1:y 2:z
mSensorManager.registerListener(this, mGyroscopeSensor, SensorManager.SENSOR_DELAY_NORMAL);
}
@Override
protected void onStart() {
super.onStart();
mGoogleApiClient.connect();
}
public void onSensorChanged(SensorEvent sensorEvent) {
new SendToDataLayerThread("/message_path", sensorEvent.sensor.getName() +" : " + (int) sensorEvent.values[0]).start();
}
class SendToDataLayerThread extends Thread {
String path;
String message;
// Constructor to send a message to the data layer
SendToDataLayerThread(String p, String msg) {
path = p;
message = msg;
}
public void run() {
NodeApi.GetConnectedNodesResult nodes = Wearable.NodeApi.getConnectedNodes(mGoogleApiClient).await();
for (Node node : nodes.getNodes()) {
MessageApi.SendMessageResult result = Wearable.MessageApi.sendMessage(mGoogleApiClient, node.getId(), path, message.getBytes()).await();
if (result.getStatus().isSuccess()) {
Log.v("myTag", "Message: {" + message + "} sent to: " + node.getDisplayName());
}
else {
// Log an error
Log.v("myTag", "ERROR: failed to send Message");
}
}
}
}
protected void onStop() {
mGoogleApiClient.disconnect();
super.onStop();
}
}
Thank you for reading my post. I hope that you find some of this information useful.
LG G Watch R Sensor List
Android Wear 2.0.0
Android 7.1
Sensor List: (Name/Type)
MPU6515 AccelerometerMPU6515 1
Gyroscope 4
HSPPAD038 Pressure 6
MPU6515 Gyroscope Uncalibrated 16
AK8963 Magnetometer 2
AK8963 Magnetometer Uncalibrated 14
MPU6515 Accelerometer -Wakeup Secondary 1
MPU6515 Gyroscope -Wakeup Secondary 4
HSPPAD038 Pressure -Wakeup Secondary 6
MPU6515 Gyroscope Uncalibrated -Wakeup Secondary 16
AK8963 Magnetometer -Wakeup Secondary 2
AK8963 Magnetometer Uncalibrated -Wakeup Secondary 14
Gravity 9
Linear Acceleration 10
Rotation Vector 11
Step Detector 18
Step Counter 19
Significant Motion Detector 17
Orientation 3
Game Rotation Vector 15
GeoMagnetic Rotation Vector 20
Tilt Detector 22
Heart Rate Monitor 21
Wrist Tilt Gesture 26
Orientation -Wakeup Secondary 3
Gravity -Wakeup Secondary 9
Linear Acceleration -Wakeup Secondary 10
Rotation Vector -Wakeup Secondary 11
Game Rotation Vector -Wakeup Secondary 15
GeoMagnetic Rotation Vector -Wakeup Secondary 20
Step Detector -Wakeup Secondary 18
Step Counter -Wakeup Secondary 19
Heart Rate Monitor -Wakeup Secondary 21
Android Wear API (Check Android Wear Sensor eventListener)
//add SensorEventListener to receive the data from sensors.
public class MainActivity extends WearableActivity implements SensorEventListener{
private static final SimpleDateFormat AMBIENT_DATE_FORMAT =
new SimpleDateFormat("HH:mm", Locale.US);
private BoxInsetLayout mContainerView;
private TextView mTextView;
private TextView mClockView;
SensorManager mSensorManager;
// Add Sensor and Listener to Recieve data from the sensor
Sensor mGyroscopeSensor;
SensorEventListener sensorEventListener;
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setAmbientEnabled();
mContainerView = (BoxInsetLayout) findViewById(R.id.container);
mTextView = (TextView) findViewById(R.id.text);
mClockView = (TextView) findViewById(R.id.clock);
mSensorManager = ((SensorManager) getSystemService(SENSOR_SERVICE));
List<Sensor> sensorList = mSensorManager.getSensorList(Sensor.TYPE_ALL);
// Get Sensor using SensorManager and add Listener on the SensorManager
mGyroscopeSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
mSensorManager.registerListener(this, mGyroscopeSensor,SensorManager.SENSOR_DELAY_FASTEST);
}
By adding implements "SensorEventListenr", we need to implement two methods.One is "onSensorChanged". The order one is "onAccuracyChanged". We just input code in the "onSensorChanged" :
@Overridepublic void onSensorChanged(SensorEvent sensorEvent) {
if(sensorEvent.sensor.getType() == Sensor.TYPE_GYROSCOPE){
// get gyroscope data.
String str="";
for(int i=0; i< sensorEvent.values.length;i++){
str=str+"GYROSCOPE " +i+":";
str=str+(int)sensorEvent.values[i];
}
mTextView.setText(str);
}
}
@Overridepublic void onAccuracyChanged(Sensor sensor, int i) {
}
Thank you for reading my post. I hope that you find some of this information useful.
Android Wear with Google fit API (Check Android Wear Sensor List)
/* You don't need it if you don't use Google fit API To use the Google Fit for Android, you need an OAuth 2.0 client ID for Android applications. Follow the link (OAuth 2.0) to obtain the OAuth 2.0 client ID.
*/
I use Android Studio to develop Android wear. I use LG G Watch R for android wear.
Create New Project:
And click "next" -> select "Empty Activity" -> "Next"->"Next" -> select "Always On Wear Activity"-> "Next" -> "Finish"
And Permissions in AndroidManifest.xml under mobile and in AndroidManifest.xml under wear like:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.lee.helloworld"> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.BODY_SENSORS" /> <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.WAKE_LOCK" /> <application
In build.gradle (Module:mobile, Module:wear) add :// you don't need it if you don't use Google fit API
compile 'com.google.android.gms:play-services-fitness:9.8.0'
My LG G Watch R's android version is 2.0.0. You can check on your android wear device by( setting -> System -> About -> version) So, I set the compile like:
compile 'com.google.android.support:wearable:2.0.0'
*If there is error in the line, plz click (Alt+ Enter) and select "Disable Inspection" *
In build.gradle(Project: Helloworld), add maven :
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com" }
}
}
Now, we are ready to program our Android wear APP.
In this poster, I only make codes in the "MainActivity" under "wear".
SensorManager mSensorManager;
@Override protected void onCreate(Bundle savedInstanceState) {//Default Code super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setAmbientEnabled(); mContainerView = (BoxInsetLayout) findViewById(R.id.container); mTextView = (TextView) findViewById(R.id.text); mClockView = (TextView) findViewById(R.id.clock);// Get the Sensor Service using SensorManager mSensorManager = ((SensorManager) getSystemService(SENSOR_SERVICE));//Get Sensor List List<Sensor> sensorList = mSensorManager.getSensorList(Sensor.TYPE_ALL); // Check Sensor list and display in TextView on your android wear.for(Sensor s: sensorList){ mTextView.setText(mTextView.getText()+s.getName()); }
And, click "Run" or Shift+F10 for running your app on Android Wear.
Thank you for reading my post. Hopefully, you found that helpful.
Linux account (change account)
(because to get same home folder name)
- Add a new user, e.g. "temporary". If you are still in TTY1 (Ctrl+Alt+F1):
set the password and just type enter$ sudo adduser temporaryexit. This should bring you to the original login prompt, if not typeexitagain. - Change the account type of your new temporary user to administrator:
In tty7 (Ctrl+Alt+F7, "normal" desktop) login in to your usual account. Change his privileges through the gui: System settings > users account. Click Unlock then change account type to "administrator". - Log out again.
- Return to tty1: Login with the 'temporary' user account and password.To change username (it is probably best to do this without being logged in):
To change home-folder, useusermod -l newUsername oldUsername
usermod -d /home/newHomeDir -m newUsername exit(until you get the login prompt)- Go back to TTY7 (Ctrl+Alt+F7) to login on the GUI/normal desktop screen and see if this works.
- Delete temporary user and folder:
sudo deluser temporary sudo rm -r /home/temporary
Ref: http://askubuntu.com/questions/34074/how-do-i-change-my-username
Java install
$sudo apt-get install software-properties-common
Install Java
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer
Network setting for Hadoop
Set static IP address

Click Internet at Top-right
Select "connection information" and "Edit Connection"
The figure will be show.
Select "Ethernet" and Click "Edit" button in the Network Connection.
Change Method "Manual" and Add Address using "connection information"
Add Hosts

$sudo nano /etc/hosts
Tip: don't add 127.0.0.1 master. It cause " org.apache.hadoop.hdfs.server.datanode.DataNode: Problem connecting to server:"
Hadoop will only listen to port 9000 and 9001 on the loopback interface, which is inaccessible from any other host. Make sure fs.default.name and mapred.job.tracker refer to your machine's externally accessible host name
add datanode like figure.
Change hostname

$sudo /etc/hostname
Change hostname like figure.
SSH Setup for Hadoop
Install openssh (at master and data node) master node and datanodes install ssh using apt-get to use ssh communication. $ sudo apt-get update sudo apt-get install openssh-server ## or sudo apt-get install $ssh sudo ufw allow 22 Set ssh (at master node) In the server make rsa key$ ssh-keygen -t rsa
Make directory at datanode
$ cat $HOME/.ssh/id_rsa.pub >> $HOME/.ssh/authorized_keys
// for connection between master.
$ ssh hadoop@data01 mkdir -p .ssh
public key copy from master node to datanode
- to its own user account on the master - i.e. ssh master in this context.
- to the master user account on the slave via a password-less SSH login.
Hadoop install (Download Hadoop-2.6)
Download hadoop from apache Hadoop or goolging
Or use wget
$ cd ~/
$ wget http://ftp.daum.net/apache/hadoop/core/stable2/hadoop-2.6.0.tar.gz
unzip
$ cd ~/
$ tar xvzf hadoop-2.6.0.tar.gz
Hadoop Install (Make Data folder & permission)
Make Folder ( at master and data node)
$ cd ~/
$ sudo mkdir -p data/hadoop/tmp
$ sudo mkdir -p data/hadoop/dfs/name
$ sudo mkdir -p data/hadoop/dfs/data
Make Linux groupadd
$sudo su -
#groupadd hadoop
#usermod -aG hadoop hadoop
// first hadoop is groud. second one is username
Authorization ( at master and data node)
$ sudo chown -R hadoop:hadoop data
$ sudo chown -R hadoop:hadoop hadoop-2.6.0
Hadoop Install (.bashrc)
$ cd ~
$ sudo nano .bashrc

export JAVA_HOME=/usr/lib/jvm/java-8-oracle
export HADOOP_HOME=/home/hadoop/hadoop-2.6.0
export HADOOP_INSTALL=$HADOOP_HOME
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export YARN_HOME=$HADOOP_HOME
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin
## set your hadoop folder location and java folder location.
after edit the bashrc file. Refresh service.
$ source ~/.bashrc
Scala install
Hadoop command
cat * > merged-file
hadoop com.sun.tools.javac.Main PearsonCorrelation.javajar cf PearsonCorrelation.jar PearsonCorrelation*.class
hadoop jar PearsonCorrelation.jar PearsonCorrelation
--multiful files
export HADOOP_CLASSPATH=$JAVA_HOME/lib/tools.jar
-compilehadoop com.sun.tools.javac.Main SmallFilesToSequenceFile.java FullFileRecordReader.java FullFileInputFormat.java
hadoop com.sun.tools.javac.Main *.java
-create jar
jar cf sfts.jar SmallFilesToSequenceFile*.class FullFile*.class
jar cf ISMR.jar ImageSimlarityMapReduce.class SimilaritySearchWithLIRE*.class WholeFileInputFormat*.class
jar cf ISMR.jar ImageSimlarityMapReduce.class SimilaritySearchWithLIRE.class WholeFileInputFormat.class WholeFileRecordReader.class
jar cf wc.jar *.class
-execute
hadoop jar sfts.jar SmallFilesToSequenceFile /user/unlv/sheep1/image /user/unlv/sheep1/aggimage1
hadoop jar imageSimlarityMapReduce.jar imageSimlarityMapReduce /home/unlv/workspace/imageProject/data/image/14985/129475963886.jpg
hadoop jar ImageSimlarityMapReduce.jar ImageSimlarityMapReduce 130054312049.jpg /user/unlv/sheep1/aggimage1 /user/unlv/sheep1/output/istest1
-count:
hdfs dfs -count /user/unlv/sheep1/image
-make directory
hdfs dfs -mkdir -p /user/unlv/sheep1/image/
-input multi file
hdfs dfs -put 1507*/* /user/unlv/sheep1/image/
java -jar ImageSimlarityMapReduce.jar /home/unlv/workspace/imageProject/data/image/14985/129475963886.jpg -XX:-UseGCOverheadLimit
-change replication
hadoop dfs -setrep -w 4 /path/to/file
use this command to find out the location of file, find #rack it is stored, what is the block name on all racks
hadoop fsck /path/to/your/directory -files -blocks -locations -racks
JVM & OS Memory check
package com.java.memory;
import java.lang.management.OperatingSystemMXBean;
public class MemoryInfo {
Runtime runtime= Runtime.getRuntime(); // jvm resource
com.sun.management.OperatingSystemMXBean bean =
(com.sun.management.OperatingSystemMXBean) java.lang.management.ManagementFactory.getOperatingSystemMXBean(); // os resource
// OS memory check
public long getFreeMemory() {
long freeMemory =bean.getFreePhysicalMemorySize();
System.out.println("Free OS Memory: "+ freeMemory);
return freeMemory;
}
public long getAllocatedMemory() {
long allocatedMemory = bean.getTotalPhysicalMemorySize() - bean.getFreePhysicalMemorySize();
System.out.println("Allocated OS Memory: "+allocatedMemory);
return allocatedMemory;
}
public long getMaxMemory() {
long maxMemory=bean.getTotalPhysicalMemorySize();
System.out.println("Max OS Memory: "+maxMemory);
return maxMemory;
}
// JVM memory check
public long getJVMFreeMemory() {
long freeMemory =runtime.freeMemory();
System.out.println("Free JVM Memory: "+ freeMemory);
return freeMemory;
}
public long getJVMAllocatedMemory() {
long allocatedMemory = runtime.totalMemory();
System.out.println("Allocated JVM Memory: "+allocatedMemory);
return allocatedMemory;
}
public long getJVMMaxMemory() {
long maxMemory=runtime.maxMemory();
System.out.println("Max JVM Memory: "+maxMemory);
return maxMemory;
}
}
//src/main/java
package com.java.memory;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.context.support.GenericXmlApplicationContext;
public class MainClass {
public static void main(String[] args) {
String configLocation="classpath:applicationCTX.xml";
AbstractApplicationContext ctx = new GenericXmlApplicationContext(configLocation);
MemoryInfo memInfo= ctx.getBean("memoryInfo",MemoryInfo.class);
memInfo.getFreeMemory();
memInfo.getJVMFreeMemory();
memInfo.getAllocatedMemory();
memInfo.getJVMAllocatedMemory();
memInfo.getMaxMemory();
memInfo.getJVMMaxMemory();
}
}
//src/main/resources/applicationCTX.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="memoryInfo" class="com.java.memory.MemoryInfo"/>
</beans>
//src/test/java
//Junit Example with memory check
package com.java.memory;
import static org.junit.Assert.*;
import org.junit.Assert;
import org.junit.Test;
public class MemoryInfoTest {
MemoryInfo MI = new MemoryInfo();
@Test
public void test() {
assertNotNull(MI.getFreeMemory());
assertNotNull(MI.getAllocatedMemory());
assertNotNull(MI.getMaxMemory());
assertNotNull(MI.getJVMFreeMemory());
assertNotNull(MI.getJVMAllocatedMemory());
assertNotNull(MI.getJVMMaxMemory());
}
}
Read Web page source using URLConnection
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.Scanner;
public class URLConn {
public static void main(String[] args) {
String code=null;
System.out.println("Input Web address: ");
Scanner scanner = new Scanner(System.in);
String address =scanner.next();
try {
URL url = new URL(address);
URLConnection con = url.openConnection();
//Read page source
BufferedReader webData= new BufferedReader(new InputStreamReader(con.getInputStream()));
FileWriter fw = new FileWriter("C:\\Users\\Downloads\\file.html");
//Write at file.html
while((code = webData.readLine())!=null){
fw.write(code);
}
System.out.println("end");
fw.close();
webData.close();
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
}
}
Install tomcat7 on Eclipse

Click "New server wizard" in the Server tap.

Select tomcat7 and click next

Tomcat installation directory: (Unziped tomcat7 folder)
JRE: select java version.
Click Finish.

Double Click mouse left button at tomcat v7.0 serve in the server tap.

Setting Server:
Check at
Server Location:
"Use Tomcat installation (takes control of Tomc installation)"
Server Options:
"Publish module context to seperate XML files"
"Modules auto reload by default"
Change port at
Ports:
Port Name: HTTP/1.1
prot Number: 8181
Save
Ctrl+ s ( for save)
Server start
Ctrl+ a;t +r ( server start)
Check at browser
http://localhost:8181/
Ganglia on Hadoop-2.7.1
OS: Ubuntu 14.04
Order
- Gmetad install at master node (name node)
- Gmond install all nodes which you want to know their source.(master + slaves)
- synchronizing between hadoop and ganglia
Ganaglia version 3.6

- Gmetad (Ganglia meta daemon): a daemon on the master node that collects data from all the Gmond daemons (and other Gmetad daemons, if applicable).
- Gmond (Ganglia monitoring daemon): a small service that collects information about a node. This is installed on every server you want monitored.
- Gmetad on master node
$sudo apt-get install -y ganglia-monitor rrdtool gmetad ganglia-webfrontend
Select yes(restart apache2) twice.
Copy /etc/ganglia-webfrontend/apache.conf to apache sites-enabled to set up online graphical dashboard.
$sudo cp /etc/ganglia-webfrontend/apache.conf /etc/apache2/sites-enabled/ganglia.conf
Edit the Gmetad configuration file to set up your cluster.
$sudo nano /etc/ganglia/gmetad.conf
change:
data_source "my cluster" localhost -> data_source "Hadoop" 60 localhost
60 is option to measure every second.
Configure for Gmond on master noode.
$sudo vi /etc/ganglia/gmond.conf
change cluster name "my cluster" to "Hadoop"

And, set host at upd section.
udp_send_channel {
#mcast_join = 239.2.11.71 ## comment out
host = localhost
port = 8649
ttl = 1
}
udp_recv_channel {
#mcast_join = 239.2.11.71 ## comment out
port = 8649
#bind = 239.2.11.71 ## comment out
}
.
Restart
$sudo service ganglia-monitor restart && sudo service gmetad restart && sudo service apache2 restart
At browser
IP address/ganglia/

2. Gmond install all nodes which you want to know their source.(each slave nodes)
$sudo apt-get update
$sudo apt-get install -y ganglia-monitor
$sudo vi /etc/ganglia/gmond.conf
===============================================================
cluster {
name = "Hadoop" ## Cluster name
owner = "unspecified"
latlong = "unspecified"
url = "unspecified"
}
udp_send_channel {
#mcast_join = 239.2.11.71 ## Comment
host = 10.10.1.1 ## IP address of master node
port = 8649
ttl = 1
}
/* You can specify as many udp_recv_channels as you like as well.
udp_recv_channel {
mcast_join = 239.2.11.71
port = 8649
bind = 239.2.11.71
}
*/
============================================================
$sudo service ganglia-monitor restart
Set up Hadoop for monitoring
3. synchronizing between hadoop and ganglia (each slave nodes)
Just remove '#' and change servers ip address to master address ip
$sudo nano /usr/local/hadoop-2.7.1/etc/hadoop/hadoop-metrics2.properties
=========================================
$sudo /usr/local/hadoop-2.7.1/sbin/hadoop-daemon.sh stop datanode
$sudo /usr/local/hadoop-2.7.1/sbin/hadoop-daemon.sh start datanode
Or, entire restart
$sudo /usr/local/hadoop-2.7.1/sbin/stop-all.sh
$sudo /usr/local/hadoop-2.7.1/sbin/start-all.sh
$sudo service ganglia-monitor restart && sudo service gmetad restart && sudo service apache2 restart
Ganglia -configuration (log location)
It makes your "/" full of size.
There are needed to move default location to other location.
mkdir -p /some/other/place/
chown -R ganglia /some/other/place/
chmod -R 777 /some/other/place/
or
chown -R nobody:root /var/lib/ganglia/rrds
sudo nano /etc/ganglia/gmetad.conf
============================================
<!-- remove # -->
rrd_rootdir "/mnt/ganglia/log"
============================================
restart service
sudo service ganglia-monitor restart && sudo service gmetad restart && sudo service apache2 restart
restart service
sudo service ganglia-monitor restart
================================================
When the graph is not work at ganglia web front
Fix graphs by symlinking rrds to /var/lib
rm -rf /var/lib/ganglia/rrds/*
rm -rf /mnt/ganglia/rrds/*
# Symlink /var/lib/ganglia/rrds to /mnt/ganglia/rrds
rmdir /var/lib/ganglia/rrds
ln -s /mnt/ganglia/rrds /var/lib/ganglia/rrds
# Make sure rrd storage directory has right permissions
mkdir -p /mnt/ganglia/rrds
chown -R nobody:nobody /mnt/ganglia/rrds
Hadoop individual restart (stop and start)
Master (name) Node
sudo /usr/local/hadoop-2.7.1/sbin/hadoop-daemon.sh stop namenode
sudo /usr/local/hadoop-2.7.1/sbin/hadoop-daemon.sh start namenode
Resource manager Node
sudo /usr/local/hadoop-2.7.1/sbin/yarn-daemon.sh stop resourcemanager
sudo /usr/local/hadoop-2.7.1/sbin/yarn-daemon.sh start resourcemanager
Slave (data) Node
sudo /usr/local/hadoop-2.7.1/sbin/yarn-daemon.sh stop nodemanager
sudo /usr/local/hadoop-2.7.1/sbin/yarn-daemon.sh start nodemanager
sudo /usr/local/hadoop-2.7.1/sbin/hadoop-daemon.sh stop datanode
sudo /usr/local/hadoop-2.7.1/sbin/hadoop-daemon.sh start datanode
Extand jobhsitory life time
#mapreduce-site.xml
<property>
<name>mapreduce.jobhistory.max-age-ms</name>
<value>5184000000</value>
</property>
Big data system
- Change Hadoop Configure
- mapred-site.xml - change local dir
- Change Replication factor (using Command)
- Extand jobhsitory life time
- Hadoop individual restart (stop and start)
- Ganglia -configuration (log location)
- Ganglia on Hadoop-2.7.1
- Hadoop command
- Hadoop Install (on Ubuntu)
- Scala install
- Hadoop install ( Verify)
- Hadoop Install (configure)
- Hadoop Install (.bashrc)
- Hadoop Install (Make Data folder & permission)
- Hadoop install (Download Hadoop-2.6)
- Linux Setup for installing Hadoop
Change Replication factor (using Command)
$ hdfs dfs -setrep -w 4 /path/to/file
You can also do this recursively. To change replication of entire HDFS to 1:
$ hdfs dfs -setrep -R -w 1 /
mapred-site.xml - change local dir
<property>
<name>mapreduce.cluster.local.dir</name>
<value>/mnt/mapred/local</value>
</property>
<property>
<name>mapreduce.cluster.local.dir</name>
<value>/mnt/mapred/local</value>
</property>
sudo nano /usr/local/hadoop-2.7.1/etc/hadoop/mapred-site.xml
Intel Edison Arduino Board (Set Auto Start Program for Zumo)
Procedure to Autostart the Arduino Sketch on Edison
https://software.intel.com/en-us/blogs/2015/08/01/procedure-to-autostart-the-arduino-sketch-on-edison-0Based on the intel developer Zone.
Step 1.
If there is not init.d in the Intel Edison,
root@edison:~# mkdir /etc/init.d
If there is init.d in the Intel Edison,
root@edison:~# cd /etc/init.d
Step 2.
Create the file "automateSketch.sh" in the init.d using "vi" command.
root@edison:/etc/init.d# vi automateSketch.sh
Step 3.
Add the follow script: ( this script is executed every time linux boots)
#!/bin/sh
sleep 10
exec /sketch/sketch.elf /dev/ttyGS0 /dev/ttyGS0
echo 214 > /sys/class/gpio/export
echo 242 > /sys/class/gpio/export
echo 263 > /sys/class/gpio/export
echo low > /sys/class/gpio/gpio214/direction
echo low > /sys/class/gpio/gpio263/direction
echo out> /sys/class/gpio/gpio242/direction
echo high> /sys/class/gpio/gpio214/direction
Zumo uses PWM 10 pin to control the right side motor.

change the Jumper in J12 like the picture.
Add "echo" code for the PWM setting in the linux.
More detail information about Multipliexing Guide:
Intel® Edison GPIO Pin Multiplexing Guide
http://www.emutexlabs.com/project/215-intel-edison-gpio-pin-multiplexing-guideStep 4.
Permission setting:
root@edison:/etc/init.d# chmod +x /etc/init.d/automateSketch.sh
root@edison:/etc/init.d# chmod +x automateSketch.sh
Step 5.
Adding system startup for /etc/init.d/automateSketch.sh
root@edison:/etc/init.d# update-rc.d automateSketch.sh defaults
(TCP/IP) Zumocontrol sketch for Intel Edison Arduino board
// pin 6 has to output with pin 10
// no need to Ethernoet setting for TCP/IP communication. Intel Edison already setup the Wifi.
#include <SPI.h>
#include <Ethernet.h>
#define PWM_L1 6 // for PWM 10
#define PWM_L 10
#define PWM_R 9
#define DIR_L 8
#define DIR_R 7
EthernetServer server(8888);
void setup() {
// put your setup code here, to run once:
// Serial.begin(9600);
server.begin();
//setPwmSwizzler(3,5,10,9); // is not working in the edison board
pinMode(10,OUTPUT);
pinMode(6,OUTPUT);
pinMode(9,OUTPUT);
pinMode(8,OUTPUT);
pinMode(7,OUTPUT);
}
boolean alreadyConnected = false;
int speed=200;
int reverse = 1;
void sstop(){
// speed = 0;
analogWrite(PWM_L1, 0);
// analogWrite(PWM_L, 0);
analogWrite(PWM_R, 0);
// analogWrite(PWM_R, speed * 51 / 80);
// digitalWrite(10, 0);
digitalWrite(6, 0);
digitalWrite(9, 0);
// Serial.write("stop");
reverse = 1;
}
void go(){
analogWrite(PWM_L1, speed * 51 / 80);
analogWrite(PWM_L, speed * 51 / 80);
analogWrite(PWM_R, speed * 51 / 80);
digitalWrite(DIR_L, 0);
digitalWrite(DIR_R, 0);
reverse = 1;
}
void back(){
analogWrite(PWM_L1, speed * 51 / 80);
analogWrite(PWM_L, speed * 51 / 80);
analogWrite(PWM_R, speed * 51 / 80);
digitalWrite(DIR_L, 1);
digitalWrite(DIR_R, 1);
reverse = -1;
//Serial.write("back");
}
void left(){
speed= speed +25;
analogWrite(PWM_L1, speed * 51 / 80);
analogWrite(PWM_L, speed * 51 / 80);
if(reverse >0){
digitalWrite(DIR_L, 1);
}else if(reverse <0){
digitalWrite(DIR_L, 0);
}
}
void right(){
speed= speed +25;
//analogWrite(PWM_L1, speed * 51 / 80);
analogWrite(PWM_R, speed * 51 / 80);
if(reverse >0){
digitalWrite(DIR_R, 1);
}else if(reverse <0){
digitalWrite(DIR_R, 0);
}
}
char command= 'n';
int count =0;
void loop() {
EthernetClient client = server.available();
// if (client) {
if (client.available() > 0) {
// read the bytes incoming from the client:
command= client.read();
// echo the bytes back to the client:
// server.write(thisChar);
// echo the bytes to the server as well:
// Serial.write(command);
// }
switch(command)
{
count++;
case 'g':
go();
client.flush();
break;
case 's':
sstop();
// Serial.write("stop");
client.flush();
break;
case 'r':
right();
client.flush();
break;
case 'l':
left();
client.flush();
break;
case 'b':
back();
client.flush();
// Serial.write("stop");
break;
}
if(count <10){
command='n';
count =0;
}
}










