Maritime counter terrorism

The global cost for maritime piracy reaches hundreds of millions. Beyond the financial aspect, these are always traumatizing crisis situations that are difficult to deal with. How can we anticipate or prevent these situations?