August 24, 2019 Vignesh Sathiyanantham

When I was writing the base code in Spring boot for my RESTifying the ZFS APIs project, I was looking for some way of throwing the exception to the user with HTTP error code. I found a way to handle it by using ResponseStatusExceptionResolver. ResponseStatusExceptionResolver is introduced with Spring 3, and Its main responsibility is to use the @ResponseStatus annotation available on custom exceptions and to map these exceptions to HTTP status codes. @ResponseStatus annotation I created a ValidationException class extending the RuntimeException class with a constructor. This is how my code looks like package in.asvignesh.zfsservice.controller; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.ResponseStatus;…

August 24, 2019 Vignesh Sathiyanantham

I am working on a new hobby project RESTifying the ZFS APIs, Earlier I was using play framework for my REST projects, now started using SpringBoot While RESTifying the ZFS API one of the API formats is like @GetMapping(path = {“/”, “/{poolname}”, “/{poolname}/{volumename}”}, produces = “application/json”) / will give all the pool name and volumes, /poolname will give all the pool name and volumes of that particular pool, /poolname/”poolname/volumename” should give the pool and the volume. The volume name is in the format {poolname}/{volumename}, so I want to provide the slash with URL encoded but given restful method below gives…

August 15, 2019 Vignesh Sathiyanantham

In this post, we will see how to install ZFS on Ubuntu and present a ZVOL through iSCSI protocol to a Windows Machine for SQL Database First I created a Linux Ubuntu x64 Virtual Machine and installed the Ubuntu 18.04 Server using the server iso file available in the Ubuntu website After installing the Ubuntu, configured the static IP and installed openssh-server sudo apt-get install openssh-server Then I proceed to install the ZFS File system in my mint ubuntu Install Software properties common sudo apt-get install software-properties-common First, you have to make sure that main, restricted, universe and multiverse software…

August 13, 2019 Vignesh Sathiyanantham

In this post will see how to secure the REST API using Basic Authentication with Spring security features. In this example, we will be using Spring boot to avoid basic configuration I will describe only the security part of Spring REST and how to test with Postman Basic Authentication in REST API Basic authentification is a standard HTTP header with the user and password encoded in base64 : Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==.The userName and password are encoded in the format username: password. This is one of the simplest technique to protect the REST resources because it does not require cookies. session…

August 8, 2019 Vignesh Sathiyanantham

I have created my own annotation with default values set overriding the existing defaults In request parameters @RequestParam you can set the required parameters, I am implementing the Get Users and Get User by Name APIs Legacy way of implementing @RequestMapping(value = “/user/{name}”) public String getUsers(@PathVariable String name) { return service.getUsers(name); } @RequestMapping(value = “/user”) public String getUsers() { return service.getUsers(); } Instead of duplicating the APIs and overloading the method we can use the Java 8 Optional Parameter @RequestMapping(value = {“/”, “/{username}”}, verb = RequestMethod.GET) public ResponseEntity<List<User>> getUsers( @PathVariable(value = “username”, required = false) Optional<String> username) { if (username.isPresent())…

July 12, 2019 Vignesh Sathiyanantham

Recently we faced an issue in our product Nimesa Cloud Data protection, our QA Director raised a bug that Nimesa is listing two networks during Virtual Machine clone but while editing the VM in vSphere web client he was getting only one network. When I checked in the vSphere web client I can see one network as Uplink port group but in the manage object browser two networks are listed and there is no difference between them to identify that as an uplink port group and ignore while listing in the clone after scratching my head and wondered “ But…

July 11, 2019 Vignesh Sathiyanantham

Removing the old snapshots of the Virtual Machine is one of the easiest ways that a virtualization administrator can reclaim storage capacity in their environment. Unlike reclaiming other resources like CPU or Memory, deleting old snapshots doesn’t require downtime. Now, many of us are guilty of having snapshots that are months old, and sometimes for reasons, we can’t even remember. But unless you have a tool like vRealize Operations Manager, finding and deleting old snapshots can be a lengthy manual process. There are multiple ways to find the old/stale VM snapshots, you can leverage some smart tools like RVTools to…

July 8, 2019 Vignesh Sathiyanantham

Java 8 has Collectors.joining() and its overloads. It also has String.join.Using a Stream and a Collector Function<String,String> addQuotes = s -> “\”” + s + “\””; String result = listOfStrings.stream() .map(addQuotes) .collect(Collectors.joining(“, “)); String result = listOfStrings.stream() .map(s -> “\”” + s + “\””) .collect(Collectors.joining(“, “)); String result = listOfString.isEmpty() ? “” : “\”” + String.join(“\”, \””, listOfStrings) + “\””; Happy Coding!

May 9, 2019 Vignesh Sathiyanantham

Changing the individual database recovery model is very simple with the Microsoft SSMS. But recently in one of our Nimesa customer environments, he had 200 databases in a non-production instance and all the databases are in the simple recovery model. That user wanted to do POC of Nimesa Application-aware backup and Point in time recovery for MS SQL database server, Log backups are not possible with the simple recovery model, so I executed a small PowerShell script which changes all the databases to the FULL recovery model from the simple recovery model Get-SqlDatabase -ServerInstance NW1\CLUST2 The above Powershell command gets…

May 2, 2019 Vignesh Sathiyanantham

Creating a full backup in the SQL server using SSMS is very simple, but if you have 10’s of databases you find bit difficult to backup all databases in one go. So i write a small Powershell script which gets the list of databases and takes the backup except the system databases https://gist.github.com/asvignesh/9c2f275c9418b038022ceffa94ba2152 Run the script with Server name and the backup directory as parameters .\BackupAllDatabases.ps1 -serverName NW\CLUST -backupDirectory c:\backupdir