Archive for the ‘Knowledge’ Category

We are about to implement MAP API2 in our project, here its Glimpse,

“https://developers.google.com/maps/documentation/android/”

  1.  do login here, https://code.google.com/apis/console/
  2.  on left side panel click on “Services”
  3.  find the service “Google Maps Android API v2” turn it on. Accept the terms and condition.
  4.  Now go back and click on “API Access”
  5.  Click on “Create new Android Key”
  6.  Paste SHA1 fingerprint there.

e.g., 9A:3D:9C:57:B6:46:E2:1C:EC:CF:BD:D3:EA:A6:B7:81:27:49:69:1A;com.example

here com.example – its an application package name

a. what is SHA1 key here?
Its a android debug keystore, where android app is Developed. when Signed APK is generated, this SHA1 will be regenerate using new keystore of application.
b. how to generate that?
open command prompt, and then

C:\Program Files\Java\jdk1.6.0_20\bin>keytool -list -v -keystore “c:\Users\admin\.android\debug.keystore”

you will prompt for password, enter “android” without qoute
It will give you the rtesult like this,

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 1 entry

Alias name: androiddebugkey
Creation date: Nov 5, 2012
Entry type: PrivateKeyEntry
Certificate chain length: 1
Certificate[1]:
Owner: CN=Android Debug, O=Android, C=US
Issuer: CN=Android Debug, O=Android, C=US
Serial number: 50975212
Valid from: Mon Nov 05 11:13:46 IST 2012 until: Wed Oct 29 11:13:46 IST 2042

Certificate fingerprints:
MD5: BD:30:DD:77:0F:BE:82:A1:20:59:46:28:E7:11:E2:C8
SHA1: 9A:3D:9C:57:B6:46:E2:1C:EC:CF:BD:D3:EA:A6:B7:81:27:49:69:1A
Signature algorithm name: SHA1withRSA
Version: 3

*******************************************
*******************************************

C:\Program Files\Java\jdk1.6.0_20\bin>

this SHA1 is of my Computer local Keystore.

After generating new aandroid key,
it will be listed in your page, with Title saying “Key for Android apps (with certificates)”
You have to give me that API Key for implement MAP in application. It will look like “AIzaSyBmWleqdGClIWXXhgMbKAt-0aBxdohmmaM”

Then and then MAP can be loaded.

NOTE: If you are not getting this then please follow this link, https://developers.google.com/maps/documentation/android/start#the_google_maps_api_key

Now lets start code in Project,

create on layout file, map_activity.xml
and paste this code,

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/asdf"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <fragment
        android:id="@+id/map"
        android:name="com.google.android.gms.maps.MapFragment"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    </fragment>

</LinearLayout>

Now, create one Class file in your project, MapActivity.java

Code it like this,


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;

import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.GoogleMap.OnMapLongClickListener;
import com.google.android.gms.maps.MapFragment;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.MarkerOptions;
import com.example.R;

public class MapActivity extends Activity {

	private final String tag = getClass().getName();

	private GoogleMap googleMap;
	private Double lat, lon;
	private LatLng latLng;

	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		 setContentView(R.layout.map_activity);

	/**
	*provide lat long
	*/
			lat =  gpsLocationTracker.getLatitude();
			lon =  gpsLocationTracker.getLongitude();

	        latLng = new LatLng(lat, lon);
	        try {

	        	googleMap = ((MapFragment)getFragmentManager().findFragmentById(R.id.map)).getMap();
				CameraPosition cp = new CameraPosition.Builder()
				.target(new LatLng(lat,lon))
				.zoom(12)
				.build();
				googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cp));

				/*adding custom marker on the map*/
				googleMap.addMarker(new MarkerOptions()
						.draggable(true)
						.position(latLng)
						.title("My First Marker")
						.snippet(""+latLng)
						.icon(BitmapDescriptorFactory
								.fromResource(R.drawable.ic_launcher)));
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

	}

	}

Now, in AndroidManifest.xml

<uses-sdk
        android:minSdkVersion="11"
        android:targetSdkVersion="16" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

    <!-- MAP API V2 -->
    <permission
        android:name="com.example.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.example.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />

    <!-- MAP API V2 -->
    <uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

now inside Application tag

<!-- MAP Api V2 -->
<!-- Place your ANDROID API KEY for MAP at res/string/mapv2 -->
        <meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="@string/mapv2" />
<activity android:name="com.plunder.utility.MapActivity" >

NOTE: Don’t forget to include Library project, you can find it here

Bigtable is a distributed storage system (built by Google) for managing structured data that is designed to scale to a very large size: petabytes of data across thousands of commodity servers.

Many projects at Google store data in Bigtable, including web indexing, Google Earth, and Google Finance. These applications place very different demands on Bigtable, both in terms of data size (from URLs to web pages to satellite imagery) and latency requirements (from backend bulk processing to real-time data serving).

Despite these varied demands, Bigtable has successfully provided a flexible, high-performance solution for all of these Google products.

Some features

* fast and extremely large-scale DBMS
* a sparse, distributed multi-dimensional sorted map, sharing characteristics of both row-oriented and column-oriented databases.
* designed to scale into the petabyte range
* it works across hundreds or thousands of machines
* it is easy to add more machines to the system and automatically start taking advantage of those resources without any reconfiguration
* each table has multiple dimensions (one of which is a field for time, allowing versioning)
* tables are optimized for GFS (Google File System) by being split into multiple tablets – segments of the table as split along a row chosen such that the tablet will be ~200 megabytes in size.

Architecture

BigTable is not a relational database. It does not support joins nor does it support rich SQL-like queries. Each table is a multidimensional sparse map. Tables consist of rows and columns, and each cell has a time stamp. There can be multiple versions of a cell with different time stamps. The time stamp allows for operations such as “select ‘n’ versions of this Web page” or “delete cells that are older than a specific date/time.”

In order to manage the huge tables, Bigtable splits tables at row boundaries and saves them as tablets. A tablet is around 200 MB, and each machine saves about 100 tablets. This setup allows tablets from a single table to be spread among many servers. It also allows for fine-grained load balancing. If one table is receiving many queries, it can shed other tablets or move the busy table to another machine that is not so busy. Also, if a machine goes down, a tablet may be spread across many other servers so that the performance impact on any given machine is minimal.

Tables are stored as immutable SSTables and a tail of logs (one log per machine). When a machine runs out of system memory, it compresses some tablets using Google proprietary compression techniques (BMDiff and Zippy). Minor compactions involve only a few tablets, while major compactions involve the whole table system and recover hard-disk space.

The locations of Bigtable tablets are stored in cells. The lookup of any particular tablet is handled by a three-tiered system. The clients get a point to a META0 table, of which there is only one. The META0 table keeps track of many META1 tablets that contain the locations of the tablets being looked up. Both META0 and META1 make heavy use of pre-fetching and caching to minimize bottlenecks in the system.

Implementation

BigTable is built on Google File System (GFS), which is used as a backing store for log and data files. GFS provides reliable storage for SSTables, a Google-proprietary file format used to persist table data.

Another service that BigTable makes heavy use of is Chubby, a highly-available, reliable distributed lock service. Chubby allows clients to take a lock, possibly associating it with some metadata, which it can renew by sending keep alive messages back to Chubby. The locks are stored in a filesystem-like hierarchical naming structure.

There are three primary server types of interest in the Bigtable system:

1. Master servers: assign tablets to tablet servers, keeps track of where tablets are located and redistributes tasks as needed.
2. Tablet servers: handle read/write requests for tablets and split tablets when they exceed size limits (usually 100MB – 200MB). If a tablet server fails, then a 100 tablet servers each pickup 1 new tablet and the system recovers.
3. Lock servers: instances of the Chubby distributed lock service. Lots of actions within BigTable require acquisition of locks including opening tablets for writing, ensuring that there is no more than one active Master at a time, and access control checking.

Example from Google’s research paper:

alt text

A slice of an example table that stores Web pages. The row name is a reversed URL. The contents column family contains the page contents, and the anchor column family contains the text of any anchors that reference the page. CNN’s home page is referenced by both the Sports Illustrated and the MY-look home pages, so the row contains columns named anchor:cnnsi.com and anchor:my.look.ca. Each anchor cell has one version; the contents column has three versions, at timestamps t3, t5, and t6.

API

Typical operations to BigTable are creation and deletion of tables and column families, writing data and deleting columns from a row. BigTable provides this functions to application developers in an API. Transactions are supported at the row level, but not across several row keys.