Skip to content

Commit

Permalink
Перевел на ручное подключение
Browse files Browse the repository at this point in the history
  • Loading branch information
avvero committed Jan 17, 2014
1 parent 64889d2 commit cec2367
Show file tree
Hide file tree
Showing 32 changed files with 9,728 additions and 2,508 deletions.
322 changes: 322 additions & 0 deletions .idea/dataSources.ids

Large diffs are not rendered by default.

14 changes: 14 additions & 0 deletions .idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

737 changes: 319 additions & 418 deletions .idea/workspace.xml

Large diffs are not rendered by default.

Binary file added file.h2.db
Binary file not shown.
4 changes: 4 additions & 0 deletions file.lock.db
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#FileLock
#Thu Jan 16 17:37:04 NOVT 2014
id=1439aa02c53b99805172d7dcab6b60e246210b9e7b1
method=file
8 changes: 4 additions & 4 deletions grails-app/conf/BootStrap.groovy
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
class BootStrap {

def socketLogService
def mongoLogService
def socketEventService
def mongoEventService

def init = { servletContext ->
// socketLogService.start()
mongoLogService.start()
// mongoEventService.start()
}
def destroy = {
// socketLogService.stop()
mongoLogService.stop()
// mongoEventService.stop()
}
}
8 changes: 4 additions & 4 deletions grails-app/conf/DataSource.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ hibernate {
environments {
development {
dataSource {
dbCreate = "create-drop" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:h2:mem:devDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
url = "jdbc:h2:file:~/h2db/longo"
}
}
test {
dataSource {
dbCreate = "update"
url = "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
url = "jdbc:h2:file:~/h2db/longo"
}
}
production {
dataSource {
dbCreate = "update"
url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000;DB_CLOSE_ON_EXIT=FALSE"
url = "jdbc:h2:file:~/h2db/longo"
properties {
maxActive = -1
minEvictableIdleTimeMillis=1800000
Expand Down
53 changes: 52 additions & 1 deletion grails-app/controllers/com/avvero/longo/FlowController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,57 @@ class FlowController {
}

def index() {
render (view: "index", model: [id: getId()])
render (view: "index", model: [collector: params.collector, id: getId()])
}

/**
* Управление источниками
* @return
*/

def sources() {
render (view: "sources", model: [
mongoConnectionConfigs: MongoConnectionConfig.findAll(),
sockets: Socket.findAll()
])
}

def addMongoConnectionConfig() {
new MongoConnectionConfig(params).save()
forward action: "sources"
}

def delMongoConnectionConfig() {
MongoConnectionConfig.findById(params.id).delete(flush: true)
forward action: "sources"
}

def addSocket() {
new Socket(params).save()
forward action: "sources"
}

def delSocket() {
Socket.findById(params.id).delete(flush: true)
forward action: "sources"
}

/**
* Подключения
* @return
*/

def connectToMongoCollector() {
def connection = MongoConnectionConfig.findById(params.id)
Collector collector = CollectorFactory.getCollector(connection)
redirect(controller: "flow", action: "index", params: [collector: collector.getName()])
}

def connectToSocketCollector() {
def connection = MongoConnectionConfig.findById(params.id)
Collector collector = CollectorFactory.getCollector(connection)
redirect(controller: "flow", action: "index", params: [collector: collector.getName()])
}


}
17 changes: 17 additions & 0 deletions grails-app/domain/com/avvero/longo/MongoConnectionConfig.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.avvero.longo

class MongoConnectionConfig {

String host
int port
String databaseName
String collectionName

static constraints = {
}

def getKey() {
return "mongo:" + this.host+":" + this.port + ":" + this.databaseName + ":" + this.collectionName
}

}
10 changes: 10 additions & 0 deletions grails-app/domain/com/avvero/longo/Socket.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.avvero.longo

class Socket {

String host
int port

static constraints = {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import org.apache.log4j.LogManager
import org.apache.log4j.net.SocketNode

@Transactional
class SocketLogService {
class SocketEventService {

ServerSocket serverSocket

def start() {
log.info("Start SocketLogService...")
log.info("Start SocketEventService...")
new Thread(new Runnable() {
@Override
void run() {
Expand All @@ -27,7 +27,7 @@ class SocketLogService {
}

def stop() {
log.info("Stop SocketLogService...")
log.info("Stop SocketEventService...")
serverSocket.close()
}

Expand Down
3 changes: 2 additions & 1 deletion grails-app/views/flow/index.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
<title></title>
<g:javascript library="jquery"/>
<g:javascript library="atmosphere-meteor"/>
<script>var id = ${id};</script>
<script>var collector = "${collector}";</script>
<script>var id = "${id}";</script>
<g:javascript library="angular"/>
<g:javascript library="application"/>
<g:javascript library="flow"/>
Expand Down
105 changes: 105 additions & 0 deletions grails-app/views/flow/sources.gsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<%--
Created by IntelliJ IDEA.
User: avvero
Date: 01.12.13
Time: 15:26
To change this template use File | Settings | File Templates.
--%>

<%@ page contentType="text/html;charset=UTF-8" %>
<html>
<head>
<meta name="layout" content="main"/>
<title></title>
<g:javascript library="jquery"/>
</head>
<body>
<div class="container">
<h3>Mongo <span class="label label-default"></span></h3>
<table class="table table-striped">
<g:each in="${mongoConnectionConfigs}" var="item">
<tr>
<td>${item.host}</td>
<td>${item.port}</td>
<td>${item.databaseName}</td>
<td>${item.collectionName}</td>
<td>
<g:form>
<input type="hidden" name="id" value="${item.id}"/>
<g:actionSubmit action="delMongoConnectionConfig" value="Удалить" class="btn btn-default">Удалить</g:actionSubmit>
<g:actionSubmit action="connectToMongoCollector" value="Подключиться" class="btn btn-default"/>
</g:form>
</td>
</tr>
</g:each>
</table>
<g:form action="addMongoConnectionConfig" class="form-horizontal" role="form">
<div class="form-group">
<label for="host" class="col-sm-2 control-label">host</label>
<div class="col-sm-10">
<input name="host" class="form-control" id="host" placeholder="host">
</div>
</div>
<div class="form-group">
<label for="port" class="col-sm-2 control-label">port</label>
<div class="col-sm-10">
<input name="port" class="form-control" id="port" placeholder="port">
</div>
</div>
<div class="form-group">
<label for="databaseName" class="col-sm-2 control-label">databaseName</label>
<div class="col-sm-10">
<input name="databaseName" class="form-control" id="databaseName" placeholder="databaseName">
</div>
</div>
<div class="form-group">
<label for="collectionName" class="col-sm-2 control-label">collectionName</label>
<div class="col-sm-10">
<input name="collectionName" class="form-control" id="collectionName" placeholder="collectionName">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<g:submitButton name="Добавить" class="btn btn-default"/>
</div>
</div>
</g:form>
<h3>Socket<span class="label label-default">New</span></h3>
<table class="table table-striped">
<g:each in="${sockets}" var="item">
<tr>
<td>${item.host}</td>
<td>${item.port}</td>
<td>
<g:form>
<input type="hidden" name="id" value="${item.id}"/>
<g:actionSubmit action="delSocket" value="Удалить" class="btn btn-default">Удалить</g:actionSubmit>
<g:actionSubmit action="connectToSocketCollector" value="Подключиться" class="btn btn-default"/>
</g:form>
</td>

</tr>
</g:each>
</table>
<g:form action="addSocket" class="form-horizontal" role="form">
<div class="form-group">
<label for="host" class="col-sm-2 control-label">host</label>
<div class="col-sm-10">
<input name="host" class="form-control" value="localhost" placeholder="host">
</div>
</div>
<div class="form-group">
<label for="port" class="col-sm-2 control-label">port</label>
<div class="col-sm-10">
<input name="port" class="form-control" placeholder="port">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<g:submitButton name="Добавить" class="btn btn-default"/>
</div>
</div>
</g:form>
</div>
</body>
</html>
2 changes: 1 addition & 1 deletion grails-app/views/layouts/main.gsp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<a href="/longo/">Home</a>
</li>
<li <g:if test="${controllerName.equals("flow")}">class="active"</g:if>>
<g:link controller="flow">Flow</g:link>
<g:link controller="flow" action="sources">Flow</g:link>
</li>
<li><a href="#contact">Contact</a></li>
</ul>
Expand Down
Loading

0 comments on commit cec2367

Please sign in to comment.