Tuesday, August 11, 2015

MongoDB restore

To use Mongo DB mongorestore command:

put db dump file in following hierarchy:

Then go parent of dump folder and type:

It will restore all backup in respective db, depends on db-name where dump files are kept.

Monday, May 18, 2015

Rest Http Status Code, Header (Request-Response)

HTTP codes used in Rest:
Http Response Code HTTP Method Response Body Contents Response code Description
200 GET, PUT, DELETE Resource No error, operation successful.
201 Created POST Resource that was created Successful creation of a resource.
202 Accepted POST, PUT, DELETE N/A The request was received.
204 No Content GET, PUT, DELETE N/A The request was processed successfully, but no response body is needed.
301 Moved Permanently GET XHTML with link Resource has moved.
303 See Other GET XHTML with link Redirection.
304 Not Modified conditional GET N/A Resource has not been modified.
400 Bad Request GET, POST, PUT, DELETE Error Message Malformed syntax or a bad query.
401 Unauthorized GET, POST, PUT, DELETE Error Message Action requires user authentication.
403 Forbidden GET, POST, PUT, DELETE Error Message Authentication failure or invalid Application ID.
404 Not Found GET, POST, PUT, DELETE Error Message Resource not found.
405 Not Allowed GET, POST, PUT, DELETE Error Message Method not allowed on resource.
406 Not Acceptable GET Error Message Requested representation not available for the resource.
408 Request Timeout GET, POST Error Message Request has timed out.
409 Resource Conflict PUT, PUT, DELETE Error Message State of the resource doesn't permit request.
410 Gone GET, PUT Error Message The URI used to refer to a resource.
411 Length Required POST, PUT Error Message The server needs to know the size of the entity body and it should be specified in the Content Length header.
412 Precondition failed GET Error Message Operation not completed because preconditions were not met.
413 Request Entity Too Large POST, PUT Error Message The representation was too large for the server to handle.
414 Request URI too long POST, PUT Error Message The URI has more than 2k characters.
415 Unsupported Type POST, PUT Error Message Representation not supported for the resource.
416 Requested Range Not Satisfiable GET Error Message Requested range not satisfiable.
500 Server Error GET, POST, PUT Error Message Internal server error.
501 Not Implemented POST, PUT, DELETE Error Message Requested HTTP operation not supported.
502 Bad Gateway GET, POST, PUT, DELETE Error Message Backend service failure (data store failure).
505 GET Error Message HTTP version not supported.

Request header in Rest:
Request Header Description
Accept Request a particular content type. Valid values: application/json, application/xml.
Accept-Encoding Request content encoding such as gzip.
Accept-Language Request a particular language. Supported where localized strings are generated, such as Updates event descriptions. Affects sort order. The lang query parameter will override this header.
Authorization Include appropriate authorization token.
Host Formats the host portion of embedded links to other social data.
If-Modified-Since Conditional GET.
If-Unmodified-Since Conditional GET.

Response header in Rest:

Response Header Description
Content-Encoding Included if content has been encoded (gzip).
Content-Language Language selected.
Content-Length. Size of response, in bytes, unless content or transfer encoding has been applied.
Content-Type Type of response.
Last-Modified The last time the resource data was modified.
Location URI of a newly created resources.
Transfer-Encoding The form of encoding used to transfer the entity to the user.

Sources: google,yahoo

Wednesday, April 15, 2015

Hadoop Terminology

  • Hadoop Ecosystem: It consists of Hadoop core project(HDFS, MapReduce) and other open source projects (Hive, Pig, Imapala, Sqoop etc) working on top of Hadoop to help in data analysis
  • PIG: High level language to  analyses large data set, internal it uses MR
  • Hive: Offers a SQL like language on top of MR
  • Imapala: develops as a way to query data in hadoop like SQL with out using MR, with low latency compare to Hive.
  • Sqoop: To migrate data from RDBMS to Hadoop
  • Flume:  To move data from external resource (logs etc) to Hadoop
  • Hbase: real time db on hdfs
  • Hue: GUI Frontend to cluster
  • Oozie: workflow management
  • Mahoot: Machine learning library

Thursday, January 15, 2015

Link between SSL, HTTPS, Certificate, Browser, Server

I have tried to draw a link between SSL, HTTPS, Certificate, Browser, Server using simple language in following steps: 

 Process of obtaining Certificate:
  •  A web site operator obtains a certificate by applying to a certificate provider (a CA that presents as a commercial retailer of certificates) with a certificate signing request. 
  • The certificate provider generate a certificate with public and private key.
  • Now web site operator send a request to certificate Authority to sign the request. For security reasons the private key is not part of the request and is not sent to the certificate authority. 
  • The certificate provider signs the request, thus producing a public certificate. 
  • During web browsing, this public certificate and public key is served to any web browser that connects to the web site and proves to the web browser that the provider believes it has issued a certificate to the owner of the web site.
 SSL flow:
    • End-user enter a secure site to connects to
    • Browser identify it site is secure, it request SSL certificate from the site.
    • SSL certificate contains following information:
      • Domain name
      • Company name
      • City
      • State
      • Country
      • Expiration date
      • issuing Authority
    • Browser verifies following three items:
      • Certificate is not expired
      • Certificate has been issued by the Authority that browser trusts
      • Certificate has been issued to browser from the site for which it has been generated
    • If any of the above condition does not meet then browser shows error for the certificate about the same. ex: This Connection is Untrusted / Certificate Error
    • With certificate Browser also receives a Public key
    • Based on this initial exchange, browser and the website then initiate the 'SSL handshake'. The SSL handshake involves the generation of shared secrets to establish a uniquely secure connection between yourself and the website. This involves following steps:
      • The browser then uses the public key, to encrypt a random symmetric encryption key and sends it to the server with the encrypted URL required as well as other encrypted http data.
      • The web server decrypts the symmetric encryption key using its private key and uses the symmetric key to decrypt the URL and http data.
    • SSL used asymmetric Public key Infrastructure (PKI). This used two keys: Public keys to encrypt and Private key to decrypt. Anything encrypted with the public key can only be decrypted by the private key and vice-versa.
    • In Symmetric Public Key Infrastructure, same key is used for encryption and decryption.