Monday, September 30, 2013

SAP HANA exercise coding

Sample code



.xsaccess

{
"exposed":true,
"authentication":[{"method":"LogonTicket"},{"method":"Basic"}]

}



header.hdbtable

table.schemaName = "WorkshopA_00";
table.tableType = COLUMNSTORE ;
table.description = "workshop order header";
table.columns = [
{name = "orderID" ;sqlType = NVARCHAR ;nullable = false ;length = 10 ;},
{name = "Createdby" ;sqlType = NVARCHAR ;nullable = false ;length = 10 ;},
{name = "Createdat" ;sqlType = DATE ;nullable = false ;},
{name = "Currency" ;sqlType = NVARCHAR ;nullable = false ;length = 10 ;},
{name = "Total" ;sqlType = DECIMAL ;nullable = false ;length = 10 ;
                                                   defaultValue = "0";}
];


table.primaryKey.pkcolumns = ["orderID"];


item.hdbtable

table.schemaName = "WorkshopG_00";
table.tableType = COLUMNSTORE ;
table.description = "workshop order item";
table.columns = [
{name = "orderID" ;sqlType = NVARCHAR ;nullable = false ;length = 10 ;},
{name = "OrderItem" ;sqlType = NVARCHAR ;nullable = false ;length = 10 ;},
{name = "ProductId" ;sqlType = NVARCHAR ;nullable = false ;length = 10 ;},
{name = "Quantity" ;sqlType = NVARCHAR ;nullable = false ;length = 5 ;},
{name = "QuantityUnit" ;sqlType = NVARCHAR ;nullable = false ;length = 5;}
];


table.primaryKey.pkcolumns = ["orderID"];


.hdbview
to join the tables

schema="WorkshopA_00";
query="select T0.\"orderID\",
              T1.\"OrderItem\",
              T0.\"Createdby\",
              T0.\"Createdat\",
              T1.\"ProductId\",
              T1.\"Quantity\",
              T1.\"QuantityUnit\"
        from \"WorkshopA_00\".\"<package>::header\" T0
        left outer join \"WorkshopA_00\".\"<package>::item\" T1
        on T0.\"orderID\" = T1.\"orderID\"
        order by T0.\"orderID\" ASC";
        depends_on_table =["<package>::header","<package>::item"];



header.hdbsequence

schema = "WorkshopA_00";
start_with = 1 ;

depends_on_table = "package::header";



.xsprivileges

{
    "privileges":[
        {
            "name": "Basic",
            "description":"Basic usage privileges"
        },
        {
            "name": "Admin",
            "description":"Administration privileges"
        }

             ]
}

workshopAdmin.hdbrole

role <package>::workshopAdmin
 extends role <package>::workshopUser
{
catalog schema "WorkshopA_00": SELECT ,INSERT ,UPDATE ,DELETE ,DROP ;
application privilege : <package>::Admin;
}

workshopUser.hdbrole 

role <package>::workshopUser {

catalog schema "WorkshopA_00": SELECT ;
application privilege : <package>::Basic;
}


To Activate role
call "_SYS_REPO"."GRANT_ACTIVATED_ROLE" ('package::workshopAdmin','uname');

SAP HANA Error / Solution

Recently I have encountered a problem while create table in SAP HANA  , I had no clue about the error .. I was getting the error from below

table.columns = [
{name = "orderID" ;sqlType = NVARCHAR ;nullable = false ;length = 10 ;},
{name = "Createdby" ;sqlType = NVARCHAR ;nullable = false ;length = 10 ;},
{name = "Createdat" ;sqlType = DATE ;nullable = false ;},
{name = "Currency" ;sqlType = NVARCHAR ;nullable = false ;length = 10 ;},
{name = "Total" ;sqlType = DECIMAL ;nullable = false ;length = 10 ;
                                                   defaultValue = "0";}

];

Error is "unable to parse  '{' expected "  .

later I found that , there is an empty line between the data and the square bracket ..

I just deleted the empty line and starting working .. quite strange :(
Hope this helps someone who is facing this issue.




Similar problem I come across recent days is that

Error : The processing instruction target matching "[xX][mM][lL]" is not allowed.

above error is occured while parsing the xml file by the application

Soln :  you might have added some space in the beginning of the application , just remove the space and f5 .



Wednesday, September 25, 2013

Encryption / decryption of DB in android ( Sqlchiper )

Encrypting database 

below link will help you , how to encrypt your data

http://sqlcipher.net/sqlcipher-for-android/


Decryption of database 

once you encrypted your db , you may need to decrypt your database .
follow below steps to decrypt your database

you need linux system to decrypt your database  or follow
http://thebugfreeblog.blogspot.in/2012/08/compiling-sqlcipher-for-windows.html  this link

download sqlcipher_2.1.1.orig.tar.gz from the below site
https://launchpad.net/ubuntu/+source/sqlcipher/2.1.1-2

or run
$ wget https://launchpad.net/ubuntu/+archive/primary/+files/sqlcipher_2.1.1.orig.tar.gz
#untar using below command
$ tar -zxvf sqlcipher_2.1.1.orig.tar.gz
$ apt-get install build-essential
$ sudo apt-get install libssl-dev
# $ cd sqlcipher-2.1.1  , go to that folder
$  ./configure --enable-tempstore=yes CFLAGS="-DSQLITE_HAS_CODEC" LDFLAGS="-lcrypto"
$  make
$ ./sqlite3 encrypted.db ;

sqlite> PRAGMA key = 'password';   -- you need to pass the password which is used while creating db.
sqlite> ATTACH DATABASE 'plaintext.db' AS plaintext KEY '';  -- empty key will disable encryption
sqlite> SELECT sqlcipher_export('plaintext');
sqlite> DETACH DATABASE plaintext;


you will get plaintext.db , you can view in SQLite Database Browser  

Tuesday, August 20, 2013

error while creating hana workspace

Error : An error occurred while getting repository client version. Repository client not properly configured

you will come across above error when you work on 32 bit OS ...  using the below steps you can get rid of it .

1. install hdbclient if it is not .
2. regi.exe is available in hdbclient  ( ex : C:\Program Files\sap\hdbclient)
3. copy the path of regi.exe 
4. Open hana studio -> window -> preferences -> expand SAP Hana Development -> repository access -> Click browse paste the copied path

click OK now you should be able to create workspace

Thursday, June 27, 2013

Speeding up your android emulator

follow the below steps to speed up your android emulator


1. enable hardware virtualization in BIOS
2. Install Intel x86 emulator accelator & Intel x86 Atom system Image from SDK manager
3. go to sdk\extras\intel\Hardware_Accelerated_Execution_Manager and install IntelHaxm.exe
4. while creating AVD select intel ATOM x86 (CPU)


thats all .. Now launch the emulator :) 

by the way ,  hardware Virtualization technology wont be available in all the system . u get this technology on intel i3 or above .


Thursday, April 4, 2013

System_server_crash


In this post I am going to discuss about system_server crash .

It is obvious to see the system server crash if you do some automated testing

the main reasons are
 1. component running in the system_server process has crashed
 2. something has caused the system_server's process primary looper
thread to deadlock


Ok,now lets take the first case component crash
   By seeing the logcat trace you can find out which component is crashing.
also you can get the call stack for this crash. you can take respective action .

lets move on to the second one , the deadlock situation
    The deadlock case is announced by a line in the
logcat buffer reading something very like this:

04-04 14:06:16.888   885  1089 W Watchdog: *** WATCHDOG KILLING SYSTEM
PROCESS: null  

when we talk about Deadlock , then we need thread's info
you can get this info in /data/anr/traces.txt

------ VM TRACES AT LAST ANR (/data/anr/traces.txt: 2011-04-04 14:06:14) ------

and the file holds *two* sets of system_process stacks.  One of them
starts like this:

----- pid 885 at 2011-04-04 14:05:42 -----
Cmd line: system_server

and the second starts like this:

----- pid 885 at 2011-04-04 14:06:12 -----
Cmd line: system_server

Note that the first was taken 30 seconds before the second, and the
second was just a few seconds before the watchdog message about
killing the system process to restart the system.  The watchdog takes
a thread snapshot after 30 seconds of the looper being unresponsive,
then another snapshot after a full minute of unresponsiveness; and
it's after that full minute that it declares the deadlock and restarts
everything.  You probably want to start with the later thread stacks,
the ones that reflect the state of affairs when the watchdog finally
gave up.

and remember , The primary system_process looper thread is titled "android.server.ServerThread"

Note:this post is crafted based on my experience and taken from some sources.

Thursday, March 21, 2013

android (Framework) bootup sequence


The System Server in Android
In this post I will add some more detail on the system server in Android. The system server is the core of the Android system
and as described in the boot sequence post it is started as soon as Dalvik is initialized and running.
The other system services will be running in the context of the System Server process.
We will start by looking at the code that runs when the System Server starts.
 This code is found in the file frameworks/base/services/java/com/android/server/SystemServer.java (in the open source project tree)
 and we will start this discussion from the main entry point.

 /**
     * This method is called from Zygote to initialize the system. This will cause the native
     * services (SurfaceFlinger, AudioFlinger, etc..) to be started. After that it will call back
     * up into init2() to start the Android services.
     */
    native public static void init1(String[] args);

    public static void main(String[] args) {
        // The system server has to run all of the time, so it needs to be
        // as efficient as possible with its memory usage.
        VMRuntime.getRuntime().setTargetHeapUtilization(0.8f);
       
        System.loadLibrary("android_servers");
        init1(args);
    }

    public static final void init2() {
        Log.i(TAG, "Entered the Android system server!");
        Thread thr = new ServerThread();
        thr.setName("android.server.ServerThread");
        thr.start();
    }

The first thing that happens is that the server will load a native library called android_servers that provides interfaces to native functionality.
Source files for this lib are placed in frameworks/base/services/jni/.
 Then the native init method that will setup native services is called, init1(args), and executed.
 The name of the function that implements this is system_init() and the it resides in frameworks/base/cmds/system_server/library/system_init.cpp.
 After setting up the native services there is a callback:


runtime->callStatic("com/android/server/SystemServer", "init2");

to init2() above to create the server thread. This thread will start the remaining services in the system according to the necessary start order.
A snippet of the initial sequence gives:

// Critical services...
        try {
            Log.i(TAG, "Starting Power Manager.");
            power = new PowerManagerService();
            ServiceManager.addService(Context.POWER_SERVICE, power);

            Log.i(TAG, "Starting Activity Manager.");
            context = ActivityManagerService.main(factoryTest);

            Log.i(TAG, "Starting telephony registry");
            ServiceManager.addService("telephony.registry", new TelephonyRegistry(context));

            AttributeCache.init(context);

            Log.i(TAG, "Starting Package Manager.");
            pm = PackageManagerService.main(context,
                    factoryTest != SystemServer.FACTORY_TEST_OFF);

            ActivityManagerService.setSystemProcess();

            mContentResolver = context.getContentResolver();

            Log.i(TAG, "Starting Content Manager.");
            ContentService.main(context,
                    factoryTest == SystemServer.FACTORY_TEST_LOW_LEVEL);

            Log.i(TAG, "Starting System Content Providers.");
            ActivityManagerService.installSystemProviders();

            Log.i(TAG, "Starting Battery Service.");
            BatteryService battery = new BatteryService(context);
            ServiceManager.addService("battery", battery);

            Log.i(TAG, "Starting Hardware Service.");
            hardware = new HardwareService(context);
            ServiceManager.addService("hardware", hardware);

            // only initialize the power service after we have started the
            // hardware service, content providers and the battery service.
            power.init(context, hardware, ActivityManagerService.getDefault(), battery);

            Log.i(TAG, "Starting Alarm Manager.");
            AlarmManagerService alarm = new AlarmManagerService(context);
            ServiceManager.addService(Context.ALARM_SERVICE, alarm);

...


We see that the power manager is started first, followed by the activity manager and the other services.
There are a lot more services started after these initial and if you are interested take look in the SystemServer.java file.
Each service is running in a separate Dalvik thread in the SystemServer process.
To give some info on the components making up the system server we may have look at it using the DDMS tool:

We see that the main Android services such as the activity manager, package manager, alarm manager etc.
are running in their separate threads but as parts of the system server process.

Thursday, March 14, 2013

In device debugging : Browser app

Hi all ,
 
  There are some additional tool/menu available to debug android browser application . By default this options is disabled.

  to enable those application ,
go to address bar in browser app , and type "about:debug" and press go ..

now open "options menu" amd  tap on  "settings" , you can find debug options there.
   
 


Friday, January 25, 2013

Finding Path in the tree


Below are the code used to find the path in the Tree

I have verified most of the cases , May be experts can give batter solution than this . As always suggestions are welcome

#include <iostream>
#include <conio.h>

using namespace std;
class node
{
public:
 int data ;
 node(int in)
 {data = in;
   left = NULL ;
   right = NULL;
 }
 node* left ;
 node* right;
};


node* findpathrootnode(int a ,int b ,node* root)
{
 if(root->data > a && root->data < b)
 {
  return root;
 }
 else
 {
  findpathrootnode(a,b,root->right);
 }
 
}

void findleftpath(int a ,node * root)
{
 if(root!= NULL &&  root->data > a)
    findleftpath(a,root->left);
 else if(root!= NULL && root->data < a)
   findleftpath(a,root->right);
 
   cout<<root->data << endl;

}

void findrightpath(int b , node * root)
{
 cout<<root->data<<endl;

 if(root!= NULL &&  root->data > b)
    findrightpath(b,root->left);
 else if(root!= NULL && root->data < b)
   findrightpath(b,root->right);

}


main()
 {

  node * obj1 = new node(5);
  node * obj2 = new node(6);
  node * obj3 = new node(4);
  node * obj4 = new node(7);
  node * obj5 = new node(8);
  node * obj6 = new node(9);

  // make tree

  obj1->left  = obj3;
  obj1->right = obj5;

  obj2->left = NULL;
  obj2->right = NULL;

  obj4->left = obj2;
  obj4->right = NULL;

  obj3->left = NULL;
  obj3->right = NULL;

  obj5->left = obj4;
  obj5->right = obj6;

  obj6->left = NULL;
  obj6->right = NULL;

  //tree in done

  node * newroot = findpathrootnode(4,7,obj1);
  findleftpath(4,newroot);
  findrightpath(7,newroot->right);
  getch();
 }

Wednesday, January 16, 2013

Logs from android

How to get Logcat logs in terminal

$  su
$  logcat -f /sdcard/logcat.txt


How to get kernel logs

$  su
$ dmesg > /sdcard/dmesg.txt

 Or run "cat /proc/kmsg > /sdcard/kmsg.txt"

of-course , when you need kernel logs you can use this .


How to get last_kmsg log

$  su
$  cat /proc/last_kmsg > /sdcard/last_kmsg.txt

This is really helpful when you phone is rebooted and you want to save last_kmsg log .

Thursday, January 3, 2013

“???????????? no permissions” when you do "adb devices"


$ adb devices
List of devices attached
????????????    no permissions

fix:
sudo -s
adb kill-server
adb start-server
adb devices