Introduction to Amazon Code Pipeline with Java part 1: basics of CI/CD

Introduction

Amazon has a relatively new service out called Code Pipeline (CP). It is a Continuous Delivery tool that enables users to run builds, tests and deploys automatically. Its purpose is similar to other CI tools such as TeamCity or Jenkins but there are some fundamental differences in the architecture and customisation options.

The company I work for had the honour to team up with Amazon and be among the first to integrate a custom job processor in CP before it was made public in June 2015. I was very fortunate to take part in this project as the developer who was responsible for writing the job processor. Our tool is a selectable option among the job processor tools of type “Test”:

Apica Loadtest in Code Pipeline

In this series we’ll take a closer look at Code Pipeline and also how a new job processor can be integrated with it using Java. It’s a large topic so the series will also consist of many posts. At this point I’m not sure yet how many there will be but 15-18 is my initial estimate since I’d like to be as detailed as possible. The AWS CP home page provides a lot of details both about the general architecture and setup. The developer pages provide the API for the CP related classes and functions.

You’ll need at least a test AWS account if you want to try the tool and have a go at building a custom job processor. However, even if you don’t have an account it can be interesting for you to learn about this new technology.

Read more of this post

Raise exception if HTTP response is other than Success

The standard way nowadays to perform a HTTP request in .NET is using the HttpClient object in the System.Net.Http namespace. There are other objects with a similar purpose, such as HttpWebRequest but HttpClient has probably become the most common.

Read more of this post

Introduction to MongoDb with .NET part 2: installation on Windows

Introduction

In the previous post we discussed the basic characteristics of MongoDb. We said that it was a NoSql database that stores its data in binary JSON, i.e. BSON documents. These documents contain collections that are somewhat like tables in relational databases. In theory any data structure that can be represented by JSON can be stored in a BSON documents. There’s no database schema, there are no constraints, you can store any (un)structured object graph in a collection as long as it can be represented in JSON. MongoDb is also highly scalable and queries have a good performance, especially if the database is tuned well. MongoDb also comes with a couple of drawbacks, such as the lack of stored procedures and transactions. You’ll need to weigh all the proc and cons before you decide which data store technology to use in your project.

In this post we’ll first install the MongoDb executables on the local machine. We’ll then see a couple of basic examples of interacting with the database server from the MongoDb client.

Read more of this post

Compressing and decompressing files with BZip2 in .NET C#

BZip2 is yet another data compression algorithm, similar to GZip and Deflate. There’s no native support for BZip2 (de)compression in .NET but there’s a NuGet package provided by icsharpcode.net.

Read more of this post

Checking whether an enum value exists by a parse test in C#

Say you have the following ShipmentOption enumeration:

public enum ShipmentOption
{
	Land,
	Sea,
	Air
}

By default each enumeration value will have an integer representation starting with 0. So 0 corresponds to Land, 1 to Sea and 2 to Air. In addition, each enumeration entry can be stringified such as “Land”, “Sea” and “Air”.

The Enum class has a TryParse method that helps you convert the string representation of the enumeration into the actual enumeration value.

Read more of this post

Introduction to MongoDb with .NET part 1: background

Introduction

MongoDb is the most popular NoSql database out there at the time of writing this post. It’s used by a wide range companies as a data store. Large and small, well-established and freshly started organisations have all embraced this relatively new database technology. The default choice for storing data in a .NET project has most often been SQL Server. While SQL Server is probably still the most popular choice for .NET developersm they can choose from other well-tested alternatives depending on their project needs. MongoDb is very easy to set up and start working with.

In this series we’ll explore a number of features of MongoDb and how it can used in a .NET project. There is already a series dedicated to MongoDb in .NET on this blog starting here. However, it was a long time ago and MongoDb, like many other technologies within IT evolve very quickly so it’s time to revisit it. Also, in this updated series I’d like to devote more time on the raw queries we can send to the MongoDb server than in the previous one. So first we’ll do some querying and data manipulation through the MongoDb shell and then we’ll go over to MongoDb in .NET.

Read more of this post

Python language basics 87: reading from a text file

Introduction

In the previous post we looked at context managers in with-blocks in Python. We said that context managers could be used with objects that require some type of opening and closing. We can open and close – or release – files. We can also open a HTTP channel to make a web request and then close it when we’re done. With-blocks makes our code more concise in that we don’t need to call the close() function anymore in code. Python will take care of that for us. In addition our code will be more robust since it can easily happen that the programmer forgets to call the close method on all open resources.

In this post we’ll look into reading text files. We’ll also see an example of multiple context managers.

Read more of this post

Python language basics 86: file I/O resource management in a context manager

Introduction

In the previous post we went through a possible improvement of our first unreliable file I/O code using try-except-finally. The code is fine, it does what it is supposed to do. However, we’re still required to actively call the close function on the file handle. We’re dealing with resource management ourselves whereas we can ask Python to take care of it for us. If we forget to include the close method in our code then the file handle will stay open leading to all sorts of problems.

This is where context managers enter the scene. It’s a scary name that might at first imply a lot of complex code. We’ll in fact see that it makes our code shorter and more readable.

Read more of this post

Creating and deleting event logs with C# .NET

The Windows event viewer contains a lot of useful information on what happens on the system:

Windows event viewer

Windows will by default write a lot of information here at differing levels: information, warning, failure, success and error. You can also write to the event log, create new logs and delete them if the code has the EventLogPermission permission. However, bear in mind that it’s quite resource intensive to write to the event logs. So don’t use it for general logging purposes to record what’s happening in your application. Use it to record major but infrequent events like shutdown, severe failure, start-up or any out-of-the-ordinary cases.

Read more of this post

TCP level communication with C# .NET: the client

In this post we saw how to set up a very simplistic TCP listener that a TCP client can connect to. We built a short demo code that can be called in a console application.

The client code is even simpler:

Read more of this post

Elliot Balynn's Blog

A directory of wonderful thoughts

Software Engineering

Web development

Disparate Opinions

Various tidbits

chsakell's Blog

WEB APPLICATION DEVELOPMENT TUTORIALS WITH OPEN-SOURCE PROJECTS

Once Upon a Camayoc

ARCHIVED: Bite-size insight on Cyber Security for the not too technical.