Skip to content
This repository has been archived by the owner on Apr 13, 2024. It is now read-only.

Add API Micro gateway deployment pattern #36

Merged
merged 14 commits into from
Apr 25, 2018
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions APIM-ISasKM-with-Analytics/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ servers:
conf_dir: api-manager-analytics/confs

-
hostname: wso2is-as-km
box: wso2is-as-km
hostname: wso2am-is-as-km
box: wso2am-is-as-km
ip: 172.28.128.6
ram: 2048
cpu: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ WORKING_DIRECTORY=/home/vagrant
JAVA_HOME=/opt/java/
WUM_HOME=/usr/local
WUM_PATH=PATH=$PATH:/usr/local/wum/bin
CONFIGURATIONS=${WORKING_DIRECTORY}/api-manager-analytics/confs
CONFIGURATIONS=${WORKING_DIRECTORY}/is-as-km/confs

# operating in non-interactive mode
export DEBIAN_FRONTEND=noninteractive
Expand Down
39 changes: 39 additions & 0 deletions APIM-Microgateway-with-Analytics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# WSO2 API Manager, API Micro-gateway with Analytics Support

In order to run this Vagrant setup, you will need an active [Free Trial Subscription](https://wso2.com/free-trial-subscription)
from WSO2 since the referring Vagrant Boxes hosted at vagrant.wso2.com contains the latest updates and fixes for WSO2 API Manager and
API Manager Analytics 2.2.0. You can sign up for a Free Trial Subscription [here](https://wso2.com/free-trial-subscription).

Access the API Publisher and Store via the URLs given below.

* API Publisher

```
https://localhost:9443/publisher/
```

* API Store

```
https://localhost:9443/store/
```

* Carbon

```
https://localhost:9443/carbon/
```

* Admin

```
https://localhost:9443/admin/
```
## Note

If you make any changes to the APIs or throttling policies, it is required to restart the API-Micro-gateway machine.

```
vagrant halt wso2am-micro-gateway
vagrant up wso2am-micro-gateway
```
106 changes: 106 additions & 0 deletions APIM-Microgateway-with-Analytics/Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# Copyright 2018 WSO2, Inc. (http://wso2.com)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License
# ------------------------------------------------------------------------

# -*- mode: ruby -*-

require 'yaml'
require 'fileutils'
require 'uri'
require 'erb'

# check whether the command is 'vagrant up'
if ARGV[0] == 'up'
print "Please insert your WSO2 credentials\n"
print "Username: "
USERNAME = STDIN.gets.chomp
print "Password: "
PASSWORD = STDIN.noecho(&:gets).chomp
print "\n"
else
# initializing USERNAME and PASSWORD
USERNAME = ""
PASSWORD = ""
end

# generate TOKEN
TOKEN = [ERB::Util.url_encode(USERNAME), ERB::Util.url_encode(PASSWORD)].join(':')

FILES_PATH = "./"
DEFAULT_MOUNT = "/home/vagrant/"
# load server configurations from YAML file
CONFIGURATIONS = YAML.load_file('config.yaml')
Vagrant.configure(2) do |config|

# changing default timeout from 300 to 1000 seconds
config.vm.boot_timeout = 1000

# loop through each server configuration specification
CONFIGURATIONS['servers'].each do |server|
# define the virtual machine configurations
config.vm.define server['hostname'] do |server_config|
# define the base Vagrant box to be used
server_config.vm.box = server['box']
# define the virtual machine host name
server_config.vm.host_name = server['hostname']

# Diasbling the synched folder
server_config.vm.synced_folder ".", "/vagrant", disabled: true

#generate the url
url = "https://"+TOKEN+"@vagrant.wso2.com/boxes/"+server['box']+".box"

server_config.vm.box_url = url

# setup network configurations for the virtual machine
# use private networking (recommended for multi-machine scenarios)
server_config.vm.network :private_network, ip: server['ip']

#forwarding ports to access the server via localhost
if server['ports']
server['ports'].each do |port|
server_config.vm.network "forwarded_port", guest: port, host: port, guest_ip: server['ip']
end
end

memory = server['ram'] ? server['ram'] : 2048
cpu = server['cpu'] ? server['cpu'] : 1
# setup VirtualBox specific provider configurations
server_config.vm.provider :virtualbox do |vb|
vb.name = server['hostname']
vb.check_guest_additions = true
vb.functional_vboxsf = false
vb.gui = false
vb.customize ['modifyvm', :id, '--memory', memory]
vb.customize ['modifyvm', :id, '--cpus', cpu]
end
if server['conf_dir']
server_config.vm.provision "file", source: FILES_PATH + server['conf_dir'], destination: DEFAULT_MOUNT + server['conf_dir']
end
# configure shell provisioner
if !server['provisioner_script']
# if not defined, move to next server specification
next
end

if server['provisioner_script_args']
# if argument(s) have been defined to be passed to the shell script
server_config.vm.provision "shell", path: server['provisioner_script'], args: server['provisioner_script_args']
else
# if no argument(s) have been defined to be passed to the shell script
server_config.vm.provision "shell", path: server['provisioner_script']
end
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<datasources-configuration>

<providers>
<provider>org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader</provider>
<!--<provider>org.wso2.carbon.datasource.reader.hadoop.HBaseDataSourceReader</provider>-->
<!--<provider>org.wso2.carbon.datasource.reader.cassandra.CassandraDataSourceReader</provider>-->
</providers>

<datasources>

<datasource>
<name>WSO2_ANALYTICS_EVENT_STORE_DB</name>
<description>The datasource used for analytics record store</description>
<definition type="RDBMS">
<configuration>
<url>jdbc:mysql://172.28.128.3:3306/stats_db?autoReconnect=true&amp;relaxAutoCommit=true</url>
<username>root</username>
<password>wso2carbon</password>
<driverClassName>com.mysql.jdbc.Driver</driverClassName>
<maxActive>50</maxActive>
<maxWait>60000</maxWait>
<validationQuery>SELECT 1</validationQuery>
<defaultAutoCommit>false</defaultAutoCommit>
<initialSize>0</initialSize>
<testWhileIdle>true</testWhileIdle>
<minEvictableIdleTimeMillis>4000</minEvictableIdleTimeMillis>
<defaultTransactionIsolation>READ_COMMITTED</defaultTransactionIsolation>
</configuration>
</definition>
</datasource>

<datasource>
<name>WSO2_ANALYTICS_PROCESSED_DATA_STORE_DB</name>
<description>The datasource used for analytics record store</description>
<definition type="RDBMS">
<configuration>
<url>jdbc:mysql://172.28.128.3:3306/stats_db?autoReconnect=true&amp;relaxAutoCommit=true</url>
<username>root</username>
<password>wso2carbon</password>
<driverClassName>com.mysql.jdbc.Driver</driverClassName>
<maxActive>50</maxActive>
<maxWait>60000</maxWait>
<validationQuery>SELECT 1</validationQuery>
<defaultAutoCommit>false</defaultAutoCommit>
<initialSize>0</initialSize>
<testWhileIdle>true</testWhileIdle>
<minEvictableIdleTimeMillis>4000</minEvictableIdleTimeMillis>
<defaultTransactionIsolation>READ_COMMITTED</defaultTransactionIsolation>
</configuration>
</definition>
</datasource>

<!-- Sample datasource implementation for HBase Analytics RecordStore-->
<!--<datasource>
<name>WSO2_ANALYTICS_RS_DB_HBASE</name>
<description>The datasource used for analytics file system</description>
<jndiConfig>
<name>jdbc/WSO2HBaseDB</name>
</jndiConfig>
<definition type="HBASE">
<configuration>
<property>
<name>hbase.master</name>
<value>localhost:60000</value>
</property>
<property>
<name>fs.hdfs.impl</name>
<value>org.apache.hadoop.hdfs.DistributedFileSystem</value>
</property>
<property>
<name>fs.file.impl</name>
<value>org.apache.hadoop.fs.LocalFileSystem</value>
</property>
</configuration>
</definition>
</datasource>-->

<!-- Sample datasource implementation for Cassandra -->
<!--<datasource>
<name>WSO2_ANALYTICS_DS_CASSANDRA</name>
<description>The Cassandra datasource used for analytics</description>
<definition type="CASSANDRA">
<configuration>
<contactPoints>localhost</contactPoints>
<port>9042</port>
<username>admin</username>
<password>admin</password>
<clusterName>cluster1</clusterName>
<compression>NONE</compression>
<poolingOptions>
<coreConnectionsPerHost hostDistance="LOCAL">8</coreConnectionsPerHost>
<maxSimultaneousRequestsPerHostThreshold hostDistance="LOCAL">1024</maxSimultaneousRequestsPerHostThreshold>
</poolingOptions>
<queryOptions>
<fetchSize>5000</fetchSize>
<consistencyLevel>ONE</consistencyLevel>
<serialConsistencyLevel>SERIAL</serialConsistencyLevel>
</queryOptions>
<socketOptions>
<keepAlive>false</keepAlive>
<sendBufferSize>150000</sendBufferSize>
<connectTimeoutMillis>12000</connectTimeoutMillis>
<readTimeoutMillis>12000</readTimeoutMillis>
</socketOptions>
</configuration>
</definition>
</datasource>-->

</datasources>

</datasources-configuration>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we remove this additional line

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<datasources-configuration xmlns:svns="http://org.wso2.securevault/configuration">

<providers>
<provider>org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader</provider>
</providers>

<datasources>
<datasource>
<name>WSO2AM_STATS_DB</name>
<description>The datasource used for setting statistics to API Manager</description>
<jndiConfig>
<name>jdbc/WSO2AM_STATS_DB</name>
</jndiConfig>
<definition type="RDBMS">
<configuration>
<url>jdbc:mysql://172.28.128.3:3306/stats_db?autoReconnect=true&amp;relaxAutoCommit=true</url>
<username>root</username>
<password>wso2carbon</password>
<driverClassName>com.mysql.jdbc.Driver</driverClassName>
<maxActive>50</maxActive>
<maxWait>60000</maxWait>
<testOnBorrow>true</testOnBorrow>
<validationQuery>SELECT 1</validationQuery>
<validationInterval>30000</validationInterval>
<defaultAutoCommit>false</defaultAutoCommit>
</configuration>
</definition>
</datasource>

</datasources>

</datasources-configuration>
Loading