Saturday, April 11, 2015

Linux, Windows 8.1 and Virtualization

I'm a Linux fan.  I like it's simplicity.  I like getting back to the command line.  However, I've just dumped Ubuntu and Linux Mint for Windows 8.1.

Backstory
In early 2014, I bought a new HP Envy 17.  It's a beast of a computer, Core i7, 8 GB RAM, 1 TB hard drive, and so on.  Good developers machine, I'd say.  I knew I could order it with Windows 7 for an extra cost, but I also knew that I had a full copy of Windows 7 Ultimate (Steve Ballmer Special Edition no less!) that I could use.  So I decided I would chuck Windows 8 and dual-boot Windows 7 and Ubuntu 13.10.

For the most part, I don't like Windows 8.  Clearly, Microsoft build this interface to serve tablets and laptops.  I'm not a fan of a touch screen laptop so I'd never have any real use of the Windows 8 "Metro" interface.  Further, I believe Windows 7 is still in good shape from what it does and how it performs.

Initially, with the dual-boot setup, I was content with the configuration.  At this point I knew nothing of running a virtual machine with VirutalBox.  I had a bit of a bug with how I had configured the system.  Apparently, I turned off UEFI and SecureBoot when all I should have done was turn off SecureBoot.  I think I thought they worked hand in hand and needed to be off together or that Linux and Windows 7 were compatible with UEFI.  Either way, the gremlin in the system was that the clock tended to be reset to GMT.  I couldn't figure out whether it was Ubuntu or Windows 7 causing that issue, but it was annoying none the less.

In the fall, I was tempted to try Linux Mint instead of Ubuntu.  I know that Linux Mint is based on Ubuntu, but the interface is what is drastically different.  Another mistake made...I wound up deleting my Windows 7 partition while installing Linux Mint.  That was awful.  Fortunately, I discovered that Linux Mint came with Oracle's VirtualBox pre-installed.  I decided to check it out and see if I should make it work with Windows 7.  It was grand.  I could get everything I wanted out of the VM without having to reboot to get into Windows 7.  When I switched to Mint I had an issue with slow wireless connectivity.  It was almost unusable sadly.  After some Googling I found that Mint was a bit behind on the Linux Kernel and an upgrade would fix the slowness.  It was a good fix.

Around December last year, I started having this issue with the wireless losing the ability to deliver Internet content, but the connection was still strong and connected.  I Googled a lot and found that a lot of folks were having issues with Linux and the Realtek wireless card.  I found an updated driver that I installed.  It helped a bit, but not a conclusive fix.  I upgraded Kernels again, no help.  It was very frustrating.  I would say for a given session with the computer the browser would drop pages 5 -10 times.  Eventually they would come back, but it was enough to slow and prevent a good flow of doing something.

About three weeks ago,  I had enough.  I decided that I would give Ubuntu 14.10 a shot and see if that fixed the issue.  My first task was to split my home directory to a separate partition.  This is a really good idea if you want to switch distributions often or even clean install the next iteration of your favorite distribution.  Once that was done, installation of Ubuntu was a breeze including the customization of the partitions to use.  Once I had everything setup,  I noticed that the same problem started happening again.  This time around, it was less often, but annoying still.

Then, I was done.  I realized through this that I had given up a bit too to use Linux.  First, this laptop came with Beats Audio.  In this case, it's three distinct speakers that can be used to improve sound.  While HP has software to help manage the sound and power consumption of the speakers, Ubuntu nor Mint have anything for Linux.  In fairness, I found some instructions on setting the speaker pins to the correct values to utilize the speakers, but since there was no power management, the speakers were on 100% of the time and using more power on battery.

Current
Just three days ago,  I backed up the home drive from Ubuntu and factory reset the computer.  With Windows 8.1 booting to the traditional Windows interface, consistency with the wireless card,  Beats Audio in place and the positive boot up speed,  I'm happy again.  I can still run my VMs now that I know more about it.  In fact, I booted up my Windows 7 VM to get some files off of there.

Now, it's off to Windows 10.  I've just loaded it onto VirtualBox....

Tuesday, December 30, 2014

Dish Network

I started with Dish Network service in 2006.  I can't complain too much about their product over the last 8, almost 9 years, of service.  They've raised their prices, and been willing to work with you on some new prices.  All satellite services will have the issue with weather equaling 'no service' so that's not a complaint to get into.

During this time, I have only had two boxes.  The first was before the major HD revolution.  When I got a new 1080p TV, I wanted the box to match, this was 2008.  Since then, I have seen over-the-air updates of the box software as new features roll out and I appreciated that.  The days of static code in a set-top box are long, long gone and I'm thankful for that.  However, the technology got old, the menu wasn't in HD and was slow to respond.  Further, my former Dish Network box (VIP722) was above my PS3 and if you just happened to leave the PS3 on, it would overheat.

As far as HD, the quality was lower than I've seen on other systems including my new Uverse service.  My wife's parents have the Hopper/Joey system and it appears that my set-top box issues may have been better with that setup, but I really didn't want to pay more for what appeared to be the same channels.  The one thing I did like was that I had one box for two TVs.  I don't like the rent-a-box model, although I do now pay $8 for an additional Uverse box, but I do recall that the Hopper/Joey was more expensive than Uverse.

The final straw was this years issues with network contracts.  I abhorred the idea of losing CBS, even if for a minute.  Dish, you should not have an issue with losing a channel that folks can get for free!  I know other channels were lost for a bit and added back.  I do appreciate Dish fighting for the best prices, but somethings I just can't get past.

When I disconnected, I already had the Uverse setup all in place, the representative on the phone did everything he could to keep me as a customer.  He said that I qualified for a $45 a month bill discount for 10 months because I was a customer for so long.  My first thought was that I had to call to get that discount.  If I was such a valued customer, I think they should have reached out to me. Also, I suspect the discount had more to do with the fact that I was cancelling than my tenure as a customer.  Of course, he was mostly nice until he realized that he couldn't do anything more for me.  Then it was like 'bye' and I was like 'do I get money back?'  Here's the kicker.  He told me that when I returned the box through shipping, I would have to pay $17 for the shipping or get my own shipping.  So let me get this straight, you just offered me $450 in discounts to stay a customer, but now that I'm leaving for sure, I have to pay you $17.  Unreal and goodbye...

Comcast

Back in 2012, I decided to switch from AT&T Phone and DSL to Comcast Cable Internet and VoIP.  While the transition was smooth and the pricing was good, the service was mostly OK.  When the service worked, and it worked 90% of the time, it was good.  Speed was excellent and the phone was clear.

This year, and mostly this year only, we had some service issues.  On two occasions we had a complete outage.  On the first one, we called and they wanted to send a technician out.  The outage was technically a massive slowdown to no response.  We were connected according to the modem, but pages weren't loading at all or the page loads were slow.  Our neighborhood has a Facebook page and many other Comcast subscribers were reporting the same issue.  Finally, Comcast picked up on the issue, either through all of the calls or through their own health checks, and fixed the issue.

When my contract ended this year, I called and negotiated a new rate.  I believe I got the 'new customer rate' and somehow that meant that my phone number would get disconnected so that they could reconnect it.  Further, in order to get the rate, I had to add a $2.50 or $3.50 a month protection plan.  Overall, the new rate was cheaper by $30 than the expired contract rate so I okay'ed it.

I didn't have much trouble disconnecting.  They didn't try to keep me as a customer too much.  That's just fine with me.  When I cancelled, I already had the Uverse equipment so I wasn't going to bend to their temptations.

AT&T Uverse and My Home Network

At my house, we recently switched away from Comcast for Internet and Phone.  For television, we had Dish Network.

I'm pretty impressed with the Uverse experience.  Internet is fast enough with 18 Mbps plan.  I've seen maximums in the 25 Mbps range as well too.  TV is clear and HD picture is better than Dish Network.  I've heard that Dish has the worst HD quality of the major providers.  In one month of usage, I haven't experienced any bad network connectivity with the TV signal.    Overall, though I'm very happy over my Comcast/Dish Network configuration.

I did a diagram of the configuration using Gliffy.


The diagram shows that I have decent separation between the TV network boxes and the Data/Computer network.  I doubt it really matters, but it seems logical to separate the two.  The N600 is necessary because I have an external storage drive that the NVG589 does not support.  Further, the GS108 switch and the N600 are on separate floors in the house.  I tried to connect the N600 to the GS108 switch, but the computer was not getting any internet responses.  I suspect that is because the TV was taking most of the traffic and somehow leaving the router out of the picture.

I've recently added another router to the picture to help with wireless range in the house.  My second floor had an RJ-45 jack in the third bedroom that goes into the basement.  I connected that to the N600 and then configured the N300 to use the same wireless details (on a different channel) as the N600.  Voila! Instant range extension!  I was looking at the 'wireless repeater' functionality, but since I had the RJ-45 jack this was a no-brainer to use.

Sunday, August 10, 2014

I've gone Android!

I had two iPhones.  I didn't think that the iPhone 6 was going to offer anything revolutionary. I realized that from a hardware perspective I was going to get about the same phone. In general, the big ticket items in a phone have been figured out. After big ticket comes small features that you probably don't need anyway. Therefore, in my mind, the last major difference is software. I figured that iOS 8 would look much like 7 as the previous versions looked all similar.

The Galaxy S5 started looking really good to me. I really do think it was just a different interface than what I was used to. Further, I was all 'Google up' with my services. Between Gmail, Drive, Contacts, and Calendar, the switch was easy. I never stored a contact locally. I always used my Google calendar for events. I've even expanded to use Picasa more with my back catalog of iPhone pictures. I uploaded every single song I have to Google Play Music for free.

It was a good switch, but hey I still have my iPad!

Saturday, July 27, 2013

Using CXF Interceptors to measure WebService or REST Service time


Let's say I have this simple service:

@WebService
public interface Hello {
     

      String sayHello();

      String sayGoodbye();

}


I want to know how often and how long sayHello() is executed compared to sayGoodbye(). I could add:

@WebService
public interface Hello { 
      
      @Profiled(tag = "sayHello")
      String sayHello();

      @Profiled(tag = "sayGoodbye")
      String sayGoodbye();

}

In this fashion, I would use Perf4Js @Profiled annotation and it would log messages telling me each time a sayHello() or sayGoodbye() method was called. However, that's not enough. I've just cut out the time of one of the most important parts of WebServices, XML processing.

Enter the CXF Interceptor, assuming of course that I was using CXF, I can write a custom interceptor by extending AbstractPhaseInterceptor<Message>, a fairly generic extension that would apply to JAXWS and JAXRS services. The new in interceptor would start a new Perf4j StopWatch (log4j or slf4j implementation if you please) and the new out interceptor would stop the StopWatch which would force the log record.  With the interceptor, I can also control the phase at which the interceptor is invoked.

Now my service would look like this:

@org.apache.cxf.interceptor.InInterceptors (interceptors = "net.halverson.interceptor.TimerInInterceptor" ) 
@org.apache.cxf.interceptor.OutInterceptors (interceptors = "net.halverson.interceptor.TimerOutInterceptor" ) 
@WebService 
public interface Hello { 
     
      String sayHello(); 

      String sayGoodbye(); 
}

But how do I know whether sayHello() or sayGoodbye() was called.  I suspect I could access the Message object in the interceptor and find out, but maybe I want more control than that.  That Message object is hanging around while my service is called and I can even place some of my own objects in it, however,  my service implementation does not have access to the Message object and I doubt I would ever want it to.

How then can I update the StopWatch with a 'tag' or 'message' for Perf4j to log?  A ThreadLocal will do.  Remember how we started the StopWatch in the in interceptor and stopped it in the out interceptor, we can use a ThreadLocal to place the StopWatch into that thread variable state and access the object across the thread without having to pass the object along the method calls in the stack.

Something like this:

public class ServiceTimer {

      private static final ThreadLocal<Slf4JStopWatch> stopWatch = new ThreadLocal<Slf4JStopWatch>() { 
              @Override
              public Slf4JStopWatch initialValue() {

                    return new Slf4JStopWatch();
              }

};

      // execute in the in interceptor, ServiceTimer.getStopWatch().start();
      // execute in the out interceptor, ServiceTimer.getStopWatch().stop();
      public static SLF4JStopWatch getStopWatch() {
            return stopWatch.get();
      }

      
      // for clean up in the out interceptor
      public static void removeWatch() {
            stopWatch.remove();
      }
}

Then in the service implementation of Hello interface:

@Service

public class HelloImpl implements Hello {

      public String sayHello() {
            ServiceTimer.getStopWatch().setTag("sayHello");

            return "Hello!";
      }

      public String sayGoodbye() {
            ServiceTimer.getStopWatch().setTag("sayGoodbye").setMessage("blah!");

            return "Goodbye!";
      }

}


In the end you'll get a two log records like this after the service is executed:

2013-07-27 10:45:45,328 INFO (http-8181-1) (TimingLogger) start[1374939945321] time[7] tag[sayGoodbye] message[blah!]
2013-07-27 10:46:03,565 INFO (http-8181-1) (TimingLogger) start[1374939963562] time[2] tag[sayHello]


See full code example here:
Github

Case # 123403984-1: JavaScript v. JSP

Opening: I've been a back-end developer (database, messaging, services, etc) all of my IT career and only done front-end (web page, scripts, graphics, etc) stuff on my own time. This week, I've exposed myself to more practical HTML, JavaScript and REST services with JSON delivery. I had previously been coding the viewing of the data in JSPs with an MVC format when needed. I've realized that the JSP / MVC model has it's uses, but the flexibility of JavaScript is what drew me in. I really liked how I could separate the presentation layer (what you see on the screen) from the data collection / back-end layer and make reusable services where you could effectively write new pages without disturbing the existing ones or the REST services behind them.

For JSP: I think the largest win here is when your page has a lot of manipulation to do and you want to run that on the server side instead of the client side. I'm sure your server cluster is more powerful and can deliver that page better than a client side rendering. The other argument I think is necessary here is hiding how the page was really built. When I write the JSP, it looks nothing like what is delivered to the consumer as all of the Java is replaced with HTML. I think that is a big positive for JSPs.

Against JSP: With JSPs, I've found that I've been a bit hard pressed to test my pages. To truly find out if my page is working, I have to start up my web app server and try to break it. When using MVC or just a servlet to deliver the page, I've found that I'm locking in the page to be delivered with the service that I just coded.
For JavaScript: In general, you can just do more with the manipulation of the page. This week, I've been able to prevent the default actions on buttons, make AJAX get and post calls, create new HTML and more. Further, with jQuery you can do a lot of JavaScript actions more simplistically. Since it's HTML and script code that is decoupled from the web app server, I can write the code in gedit/Notepad and test in the browser while my web app server is always up.

Against JavaScript: For me, the notation is a bit clunky to get started with. The use of functions compared to Java methods doesn't really match up where it's still called 'Java'. The other draw back is that you have to get used to how a browser processes a page to manipulate it. This is very different for a back-end developer.

Summation: JavaScript is another tool in my box now and I think I might have to use it more than I used JSPs. I do like how I can build those REST services and use them at will. I like how I can develop a new page to replace the old one without disturbing the existing one or writing a new service. Testing is a big win since I don't have to recycle the web app server when I make changes.